fix udl_compiled_string with non-byte chars (e.g. wchar) (#2242)

This commit is contained in:
Alexey Ochapov 2021-04-19 18:29:35 +03:00 committed by GitHub
parent c5d4fcb119
commit 1d4199f46b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 2 deletions

View File

@ -947,8 +947,9 @@ size_t formatted_size(const CompiledFormat& cf, const Args&... args) {
#if FMT_USE_NONTYPE_TEMPLATE_PARAMETERS #if FMT_USE_NONTYPE_TEMPLATE_PARAMETERS
inline namespace literals { inline namespace literals {
template <detail::fixed_string Str> template <detail::fixed_string Str>
constexpr detail::udl_compiled_string<remove_cvref_t<decltype(Str.data[0])>, constexpr detail::udl_compiled_string<
sizeof(Str.data), Str> remove_cvref_t<decltype(Str.data[0])>,
sizeof(Str.data) / sizeof(decltype(Str.data[0])), Str>
operator""_cf() { operator""_cf() {
return {}; return {};
} }

View File

@ -316,6 +316,7 @@ TEST(CompileTest, CompileFormatStringLiteral) {
using namespace fmt::literals; using namespace fmt::literals;
EXPECT_EQ("", fmt::format(""_cf)); EXPECT_EQ("", fmt::format(""_cf));
EXPECT_EQ("42", fmt::format("{}"_cf, 42)); EXPECT_EQ("42", fmt::format("{}"_cf, 42));
EXPECT_EQ(L"42", fmt::format(L"{}"_cf, 42));
} }
#endif #endif