diff --git a/include/fmt/ostream.h b/include/fmt/ostream.h index 8af60c0d..659cbaf3 100644 --- a/include/fmt/ostream.h +++ b/include/fmt/ostream.h @@ -112,9 +112,11 @@ struct fallback_formatter< // Disable conversion to int if T has an overloaded operator<< which is a free // function (not a member of std::ostream). -template struct convert_to_int { - static const bool value = convert_to_int::value && - !internal::is_streamable::value; +template +struct convert_to_int< + T, Char, + typename std::enable_if::value>::type> { + static const bool value = false; }; template diff --git a/test/ostream-test.cc b/test/ostream-test.cc index e60db62d..b566637b 100644 --- a/test/ostream-test.cc +++ b/test/ostream-test.cc @@ -6,6 +6,21 @@ // For the license information refer to format.h. #define FMT_STRING_ALIAS 1 +#include "fmt/format.h" + +struct test {}; + +// Test that there is no issues with specializations when fmt/ostream.h is +// included after fmt/format.h. +namespace fmt { +template <> struct formatter : formatter { + template + typename FormatContext::iterator format(const test&, FormatContext& ctx) { + return formatter::format(42, ctx); + } +}; +} // namespace fmt + #include "fmt/ostream.h" #include