From b96e2ff9d8c56bad68b5dd10e3a601f12496ae36 Mon Sep 17 00:00:00 2001 From: Michael de Lang Date: Wed, 26 Feb 2020 23:43:45 +0100 Subject: libstdc++: Implement constexpr std::basic_string for C++20 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. --- libstdc++-v3/include/std/version | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'libstdc++-v3/include/std/version') diff --git a/libstdc++-v3/include/std/version b/libstdc++-v3/include/std/version index 0930de8..fd7e125 100644 --- a/libstdc++-v3/include/std/version +++ b/libstdc++-v3/include/std/version @@ -232,7 +232,11 @@ #define __cpp_lib_constexpr_memory 201811L #define __cpp_lib_constexpr_numeric 201911L #ifdef __cpp_lib_is_constant_evaluated -# define __cpp_lib_constexpr_string 201811L +# if _GLIBCXX_USE_CXX11_ABI +# define __cpp_lib_constexpr_string 201907L +# else +# define __cpp_lib_constexpr_string 201811L +# endif #endif #define __cpp_lib_constexpr_string_view 201811L #define __cpp_lib_constexpr_tuple 201811L -- cgit v1.1