diff --git a/include/fmt/ostream.h b/include/fmt/ostream.h index 394d947c..ced05f75 100644 --- a/include/fmt/ostream.h +++ b/include/fmt/ostream.h @@ -142,12 +142,13 @@ struct basic_ostream_formatter : formatter, Char> { using ostream_formatter = basic_ostream_formatter; -template -struct formatter> : ostream_formatter { +template +struct formatter, Char> + : basic_ostream_formatter { template auto format(detail::streamed_view view, - basic_format_context& ctx) const -> OutputIt { - return ostream_formatter::format(view.value, ctx); + basic_format_context& ctx) const -> OutputIt { + return basic_ostream_formatter::format(view.value, ctx); } }; diff --git a/test/xchar-test.cc b/test/xchar-test.cc index ea8bc85a..290f5ffa 100644 --- a/test/xchar-test.cc +++ b/test/xchar-test.cc @@ -229,6 +229,19 @@ TEST(xchar_test, enum) { EXPECT_EQ(L"0", fmt::format(L"{}", unstreamable_enum())); } +struct streamable_and_unformattable {}; + +auto operator<<(std::wostream& os, streamable_and_unformattable) + -> std::wostream& { + return os << L"foo"; +} + +TEST(xchar_test, streamed) { + EXPECT_FALSE(fmt::is_formattable()); + EXPECT_EQ(fmt::format(L"{}", fmt::streamed(streamable_and_unformattable())), + L"foo"); +} + TEST(xchar_test, sign_not_truncated) { wchar_t format_str[] = { L'{', L':',