@@ -48,11 +48,18 @@
# include <string_view>
#endif
-
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
+#if __cplusplus == 201703L
+// Support P0426R1 changes to char_traits in C++17.
+# define __cpp_lib_constexpr_string 201611L
+#else
+// Also support P1032R1 in C++20 (but not P0980R1 yet).
+# define __cpp_lib_constexpr_string 201811L
+#endif
+
#if _GLIBCXX_USE_CXX11_ABI
_GLIBCXX_BEGIN_NAMESPACE_CXX11
/**
@@ -131,6 +131,7 @@
#define __cpp_lib_clamp 201603
#if __cplusplus == 201703L // N.B. updated value in C++20
# define __cpp_lib_constexpr_char_traits 201611L
+# define __cpp_lib_constexpr_string 201611L
#endif
#define __cpp_lib_enable_shared_from_this 201603
#define __cpp_lib_execution 201902L // FIXME: should be 201603L
@@ -219,6 +220,7 @@
#define __cpp_lib_constexpr_iterator 201811L
#define __cpp_lib_constexpr_memory 201811L
#define __cpp_lib_constexpr_numeric 201911L
+#define __cpp_lib_constexpr_string 201811L
#define __cpp_lib_constexpr_string_view 201811L
#define __cpp_lib_constexpr_tuple 201811L
#define __cpp_lib_constexpr_utility 201811L
@@ -73,12 +73,17 @@ 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 < (__cplusplus == 201703 ? 201611 : 201811)
+# error Feature-test macro for constexpr char_traits has the wrong value
+#endif
+
+// We also provide this non-standard macro for P0426R1 (and P1032R1 in C++20).
#ifndef __cpp_lib_constexpr_char_traits
# error Feature-test macro for constexpr char_traits is missing
-#elif __cpp_lib_constexpr_char_traits < 201611
+#elif __cpp_lib_constexpr_char_traits != (__cplusplus == 201703 ? 201611 : 201811)
# error Feature-test macro for constexpr char_traits has the wrong value
-#elif __cpp_lib_constexpr_char_traits > 201611 && __cplusplus == 201703
-# error Feature-test macro for constexpr char_traits has wrong value for C++17
#endif
static_assert( test_assign<std::char_traits<char>>() );
@@ -30,6 +30,13 @@ template<typename CT>
return s1[0]==char_type{1} && s1[1]==char_type{1} && s1[2]==char_type{2};
}
+#ifndef __cpp_lib_constexpr_string
+# error Feature-test macro for constexpr char_traits is missing
+#elif __cpp_lib_constexpr_string < 201811
+# error Feature-test macro for constexpr char_traits has the wrong value
+#endif
+
+// We also provide this non-standard macro for P0426R1 and P1032R1.
#ifndef __cpp_lib_constexpr_char_traits
# error Feature-test macro for constexpr char_traits is missing
#elif __cpp_lib_constexpr_char_traits != 201811
new file mode 100644
@@ -0,0 +1,16 @@
+// { dg-do compile { target c++17 } }
+
+#include <version>
+
+#ifndef __cpp_lib_constexpr_string
+# error Feature-test macro for constexpr char_traits is missing in <version>
+#elif __cpp_lib_constexpr_string < (__cplusplus == 201703 ? 201611 : 201811)
+# error Feature-test macro for constexpr char_traits has the wrong value in <version>
+#endif
+
+// We also provide this non-standard macro for P0426R1 and P1032R1.
+#ifndef __cpp_lib_constexpr_char_traits
+# error Feature-test macro for constexpr char_traits is missing in <version>
+#elif __cpp_lib_constexpr_char_traits != (__cplusplus == 201703 ? 201611 : 201811)
+# error Feature-test macro for constexpr char_traits has the wrong value in <version>
+#endif