Oops, the subject line was not supposed to say 2/2 for this commit, and I was not supposed to have Michael de Lang as the author ... I messed up my git send-email and git cherry-pick commands!
Sorry Michael, I originally tried to use your tests from https://github.com/Oipo/gcc/ but as noted in https://gcc.gnu.org/PR93989 those tests are incorrect, and so I didn't actually use any of them (nor the std::string code itself). But apparently the commit still had you as the author, because I reset the content of the git tree, but not the commit author. I'll fix that in GCC's ChangeLog file after it regenerates overnight. On Tue, 16 Nov 2021 at 16:47, Jonathan Wakely wrote: > From: Michael de Lang > > Tested x86_64-linux, committed to trunk. > > > This is only supported for the cxx11 ABI, not for COW strings. > > libstdc++-v3/ChangeLog: > > * include/bits/basic_string.h (basic_string, operator""s): Add > constexpr for C++20. > (basic_string::basic_string(basic_string&&)): Only copy > initialized portion of the buffer. > (basic_string::basic_string(basic_string&&, const Alloc&)): > Likewise. > * include/bits/basic_string.tcc (basic_string): Add constexpr > for C++20. > (basic_string::swap(basic_string&)): Only copy initialized > portions of the buffers. > (basic_string::_M_replace): Add constexpr implementation that > doesn't depend on pointer comparisons. > * include/bits/cow_string.h: Adjust comment. > * include/ext/type_traits.h (__is_null_pointer): Add constexpr. > * include/std/string (erase, erase_if): Add constexpr. > * include/std/version (__cpp_lib_constexpr_string): Update > value. > * testsuite/21_strings/basic_string/cons/char/constexpr.cc: > New test. > * testsuite/21_strings/basic_string/cons/wchar_t/constexpr.cc: > New test. > * testsuite/21_strings/basic_string/literals/constexpr.cc: > New test. > * testsuite/21_strings/basic_string/modifiers/constexpr.cc: New > test. > * > testsuite/21_strings/basic_string/modifiers/swap/char/constexpr.cc: > New test. > * > testsuite/21_strings/basic_string/modifiers/swap/wchar_t/constexpr.cc: > New test. > * testsuite/21_strings/basic_string/version.cc: New test. > > >