Skip to content

Commit

Permalink
fix udl_compiled_string with non-byte chars (e.g. wchar) (#2242)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexezeder authored Apr 19, 2021
1 parent c5d4fcb commit 1d4199f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
5 changes: 3 additions & 2 deletions include/fmt/compile.h
Original file line number Diff line number Diff line change
Expand Up @@ -947,8 +947,9 @@ size_t formatted_size(const CompiledFormat& cf, const Args&... args) {
#if FMT_USE_NONTYPE_TEMPLATE_PARAMETERS
inline namespace literals {
template <detail::fixed_string Str>
constexpr detail::udl_compiled_string<remove_cvref_t<decltype(Str.data[0])>,
sizeof(Str.data), Str>
constexpr detail::udl_compiled_string<
remove_cvref_t<decltype(Str.data[0])>,
sizeof(Str.data) / sizeof(decltype(Str.data[0])), Str>
operator""_cf() {
return {};
}
Expand Down
1 change: 1 addition & 0 deletions test/compile-test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,7 @@ TEST(CompileTest, CompileFormatStringLiteral) {
using namespace fmt::literals;
EXPECT_EQ("", fmt::format(""_cf));
EXPECT_EQ("42", fmt::format("{}"_cf, 42));
EXPECT_EQ(L"42", fmt::format(L"{}"_cf, 42));
}
#endif

Expand Down

0 comments on commit 1d4199f

Please sign in to comment.