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>
@@ -165,10 +151,8 @@ struct ToNastyChar {
165151template <std::size_t N>
166152ToNastyChar (const char (&)[N]) -> ToNastyChar<N>;
167153
168- template <ToNastyChar t>
169- constexpr auto to_nasty_char () {
170- return t;
171- }
154+ template <ToNastyChar Str>
155+ inline constexpr auto static_nasty_text = Str;
172156
173157// A macro like MAKE_CSTRING
174158//
@@ -178,13 +162,12 @@ constexpr auto to_nasty_char() {
178162# define CONVERT_TO_CSTRING (CHAR, STR ) \
179163 []<class CharT > { \
180164 if constexpr (std::is_same_v<CharT, nasty_char>) { \
181- static constexpr auto result = to_nasty_char<STR>(); \
182- return result.text ; \
165+ return static_nasty_text<STR>.text ; \
183166 } else \
184167 return MAKE_CSTRING (CharT, STR); \
185168 }.template operator ()<CHAR>() /* */
186- #else // TEST_HAS_NO_NASTY_STRING
169+ #else // TEST_STD_VER >= 20
187170# define CONVERT_TO_CSTRING (CharT, STR ) MAKE_CSTRING(CharT, STR)
188- #endif // TEST_HAS_NO_NASTY_STRING
171+ #endif // TEST_STD_VER >= 20
189172
190- #endif // TEST_SUPPORT_NASTY_STRING_H
173+ #endif // TEST_SUPPORT_NASTY_STRING_H
0 commit comments