2323// library uses the provided `CharTraits` instead of using operations on
2424// the value_type directly.
2525
26-
27- // When using the code during constant evaluation it relies on
28- // P2647R1 Permitting static constexpr variables in constexpr functions
29- // This is a C++23 feature, which is not supported by all compilers yet.
30- // * GCC >= 13
31- // * Clang >= 16
32- // * MSVC no support yet
33- //
34- // TODO After there is proper compiler support use TEST_STD_VER >= 23 instead
35- // of this macro in the tests.
36- #if TEST_STD_VER < 23 || __cpp_constexpr < 202211L
37- # define TEST_HAS_NO_NASTY_STRING
38- #endif
39-
40- #ifndef TEST_HAS_NO_NASTY_STRING
26+ #if TEST_STD_VER >= 20
4127// Make sure the char-like operations in strings do not depend on the char-like type.
4228struct nasty_char {
4329 template <typename T>
@@ -162,13 +148,8 @@ struct ToNastyChar {
162148 nasty_char text[N];
163149};
164150
165- template <std::size_t N>
166- ToNastyChar (const char (&)[N]) -> ToNastyChar<N>;
167-
168- template <ToNastyChar t>
169- constexpr auto to_nasty_char () {
170- return t;
171- }
151+ template <ToNastyChar Str>
152+ inline constexpr auto static_nasty_text = Str;
172153
173154// A macro like MAKE_CSTRING
174155//
@@ -178,13 +159,12 @@ constexpr auto to_nasty_char() {
178159# define CONVERT_TO_CSTRING (CHAR, STR ) \
179160 []<class CharT > { \
180161 if constexpr (std::is_same_v<CharT, nasty_char>) { \
181- static constexpr auto result = to_nasty_char<STR>(); \
182- return result.text ; \
162+ return static_nasty_text<STR>.text ; \
183163 } else \
184164 return MAKE_CSTRING (CharT, STR); \
185165 }.template operator ()<CHAR>() /* */
186- #else // TEST_HAS_NO_NASTY_STRING
166+ #else // TEST_STD_VER >= 20
187167# define CONVERT_TO_CSTRING (CharT, STR ) MAKE_CSTRING(CharT, STR)
188- #endif // TEST_HAS_NO_NASTY_STRING
168+ #endif // TEST_STD_VER >= 20
189169
190- #endif // TEST_SUPPORT_NASTY_STRING_H
170+ #endif // TEST_SUPPORT_NASTY_STRING_H
0 commit comments