23
23
// library uses the provided `CharTraits` instead of using operations on
24
24
// the value_type directly.
25
25
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
41
27
// Make sure the char-like operations in strings do not depend on the char-like type.
42
28
struct nasty_char {
43
29
template <typename T>
@@ -165,10 +151,8 @@ struct ToNastyChar {
165
151
template <std::size_t N>
166
152
ToNastyChar (const char (&)[N]) -> ToNastyChar<N>;
167
153
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;
172
156
173
157
// A macro like MAKE_CSTRING
174
158
//
@@ -178,13 +162,12 @@ constexpr auto to_nasty_char() {
178
162
# define CONVERT_TO_CSTRING (CHAR, STR ) \
179
163
[]<class CharT > { \
180
164
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 ; \
183
166
} else \
184
167
return MAKE_CSTRING (CharT, STR); \
185
168
}.template operator ()<CHAR>() /* */
186
- #else // TEST_HAS_NO_NASTY_STRING
169
+ #else // TEST_STD_VER >= 20
187
170
# define CONVERT_TO_CSTRING (CharT, STR ) MAKE_CSTRING(CharT, STR)
188
- #endif // TEST_HAS_NO_NASTY_STRING
171
+ #endif // TEST_STD_VER >= 20
189
172
190
- #endif // TEST_SUPPORT_NASTY_STRING_H
173
+ #endif // TEST_SUPPORT_NASTY_STRING_H
0 commit comments