]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libstdc++: Define __cpp_lib_constexpr_string macro
authorJonathan Wakely <jwakely@redhat.com>
Wed, 28 Apr 2021 14:56:04 +0000 (15:56 +0100)
committerJonathan Wakely <jwakely@redhat.com>
Thu, 29 Apr 2021 11:14:17 +0000 (12:14 +0100)
As noted in r11-1339-gb6ab9ecd550227684643b41e9e33a4d3466724d8 we define
a non-standard __cpp_lib_constexpr_char_traits feature test macro to
indicate support for P0426R1 and P1032R1. At some point last year the
__cpp_lib_constexpr_string macro was retconned to indicate support for
those papers. This adds the new macro (which we didn't previously
define, because it referred to P0980R1 "Making std::string constexpr"
which we don't support).

libstdc++-v3/ChangeLog:

* include/bits/basic_string.h (__cpp_lib_constexpr_string): Define.
* testsuite/21_strings/char_traits/requirements/constexpr_functions_c++17.cc:
Check for __cpp_lib_constexpr_string.

(cherry picked from commit 3da80ed7efd582575e7850a403ce693ec882d087)

libstdc++-v3/include/bits/basic_string.h
libstdc++-v3/testsuite/21_strings/char_traits/requirements/constexpr_functions_c++17.cc

index 0f5d398fcf24c32bfc593e18b771a4f42eb85ae8..0be11c0c444cb3425fc4c972b2dd2f07684fd910 100644 (file)
 # include <string_view>
 #endif
 
-
 namespace std _GLIBCXX_VISIBILITY(default)
 {
 _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
+#define __cpp_lib_constexpr_string 201611L
+
 #if _GLIBCXX_USE_CXX11_ABI
 _GLIBCXX_BEGIN_NAMESPACE_CXX11
   /**
index 87ea4d89a623fad08acba12a9f59132ae6552743..6a5ea249752bde4ceb9ba286b15bcac7d145541f 100644 (file)
@@ -73,6 +73,13 @@ template<typename CT>
     return true;
   }
 
+#ifndef __cpp_lib_constexpr_string
+# error Feature-test macro for constexpr char_traits is missing
+#elif __cpp_lib_constexpr_string < 201611
+# error Feature-test macro for constexpr char_traits has the wrong value
+#endif
+
+// We also provide this non-standard macro for P0426R1.
 #ifndef __cpp_lib_constexpr_char_traits
 # error Feature-test macro for constexpr char_traits is missing
 #elif __cpp_lib_constexpr_char_traits != 201611