[PATCH] D103935: Add Twine support for std::string_view.
David Blaikie via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 16 09:49:06 PDT 2021
dblaikie added a comment.
Yeah, the current state of this is not acceptable - compatibility across different standard versions is necessary.
In D103935#2881775 <https://reviews.llvm.org/D103935#2881775>, @dexonsmith wrote:
> @dblaikie / @lhames , maybe one of you has ideas for how to add Twine support for std::string_view in C++17 and later without changing Twine's ABI?
>
> I think the following won't work, because the lifetime of the StringRef wouldn't be extended to match the lifetime of the calling expression:
>
> Twine(const std::string_view &view) : Twine(StringRef(view)) {}
Yep.
Would it be so bad if we made "Child" larger by storing a StringRef (or equivalent - anything involving a pointer+length) in it (so Child would be two words rather than one)? Then we could collapse several cases into that (StringRef, string_view, std::string, SmallString, (could even do char as well)).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D103935/new/
https://reviews.llvm.org/D103935
More information about the llvm-commits
mailing list