From 171a020c828669490b98af0c2640e50f1511d2cc Mon Sep 17 00:00:00 2001 From: Nico Rieck Date: Wed, 24 May 2023 23:50:47 +0200 Subject: [PATCH] Pass correct Char to base format_as formatter (#3457) --- include/fmt/format.h | 4 ++-- test/xchar-test.cc | 9 +++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/include/fmt/format.h b/include/fmt/format.h index aae28016..92826799 100644 --- a/include/fmt/format.h +++ b/include/fmt/format.h @@ -4104,8 +4104,8 @@ class format_int { template struct formatter::value>> - : private formatter> { - using base = formatter>; + : private formatter, Char> { + using base = formatter, Char>; using base::parse; template diff --git a/test/xchar-test.cc b/test/xchar-test.cc index b5cf3351..f80997d6 100644 --- a/test/xchar-test.cc +++ b/test/xchar-test.cc @@ -152,6 +152,15 @@ TEST(xchar_test, vformat_to) { EXPECT_EQ(L"42", w); } +namespace test { +struct struct_as_wstring_view {}; +auto format_as(struct_as_wstring_view) -> fmt::wstring_view { return L"foo"; } +} // namespace test + +TEST(xchar_test, format_as) { + EXPECT_EQ(fmt::format(L"{}", test::struct_as_wstring_view()), L"foo"); +} + TEST(format_test, wide_format_to_n) { wchar_t buffer[4]; buffer[3] = L'x';