diff --git a/libcxx/test/support/make_string.h b/libcxx/test/support/make_string.h --- a/libcxx/test/support/make_string.h +++ b/libcxx/test/support/make_string.h @@ -39,13 +39,13 @@ const char16_t* u16; const char32_t* u32; - operator const char*() const { return s; } - operator const wchar_t*() const { return w; } + constexpr operator const char*() const { return s; } + constexpr operator const wchar_t*() const { return w; } #if TEST_STD_VER > 17 && defined(__cpp_char8_t) - operator const char8_t*() const { return u8; } + constexpr operator const char8_t*() const { return u8; } #endif - operator const char16_t*() const { return u16; } - operator const char32_t*() const { return u32; } + constexpr operator const char16_t*() const { return u16; } + constexpr operator const char32_t*() const { return u32; } }; // Helper to convert a const char* string to a basic_string. @@ -56,4 +56,10 @@ static_cast(MultiStringType MKSTR(Str)) \ } +// Helper to convert a const char* string to a const CharT*. +// This helper is used in unit tests to make them generic. The input should be +// valid ASCII which means the input is also valid UTF-8. +#define MAKE_CSTRING(CharT, Str) \ + static_cast(MultiStringType MKSTR(Str)) + #endif