diff --git a/include/fmt/ostream.h b/include/fmt/ostream.h index 480ddfcb..0b1a4a02 100644 --- a/include/fmt/ostream.h +++ b/include/fmt/ostream.h @@ -68,9 +68,7 @@ class is_streamable { typedef decltype(test(0)) result; public: - // std::string operator<< is not considered user-defined because we handle strings - // specially. - static const bool value = result::value && !std::is_same::value; + static const bool value = result::value; }; // Disable conversion to int if T has an overloaded operator<< which is a free @@ -111,7 +109,10 @@ void format_value(basic_buffer &buffer, const T &value) { // Formats an object of type T that has an overloaded ostream operator<<. template struct formatter::value>::type> + typename std::enable_if< + internal::is_streamable::value && + !internal::format_type< + typename buffer_context::type, T>::value>::type> : formatter, Char> { template diff --git a/test/ostream-test.cc b/test/ostream-test.cc index 3623d7ea..0f6bb793 100644 --- a/test/ostream-test.cc +++ b/test/ostream-test.cc @@ -191,3 +191,10 @@ TEST(FormatTest, FormatToN) { EXPECT_EQ(buffer + 3, result.out); EXPECT_EQ("xABx", fmt::string_view(buffer, 4)); } + +#if FMT_USE_USER_DEFINED_LITERALS +TEST(FormatTest, UDL) { + using namespace fmt::literals; + EXPECT_EQ("{}"_format("test"), "test"); +} +#endif