From 5efb24dd2b0a64c8e826c69c70d1fded5e8571a6 Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Fri, 19 Apr 2019 17:02:31 -0700 Subject: [PATCH] Add specialization test --- include/fmt/ostream.h | 8 +++++--- test/ostream-test.cc | 15 +++++++++++++++ 2 files changed, 20 insertions(+), 3 deletions(-) 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