From 6ec1ba55154786829a20ee524595179d077d5aea Mon Sep 17 00:00:00 2001 From: Alexey Ochapov Date: Wed, 19 Aug 2020 22:17:17 +0300 Subject: [PATCH] use conditional_t inside detail::write instead of 2 overloads --- include/fmt/format.h | 30 +++++++++++------------------- 1 file changed, 11 insertions(+), 19 deletions(-) diff --git a/include/fmt/format.h b/include/fmt/format.h index a862309a..36fed37b 100644 --- a/include/fmt/format.h +++ b/include/fmt/format.h @@ -1842,25 +1842,17 @@ OutputIt write(OutputIt out, const void* value) { } template >::value)> -auto write(OutputIt out, const T& value) -> typename std::enable_if< - mapped_type_constant>::value == - type::custom_type, - OutputIt>::type { - basic_format_context ctx(out, {}, {}); - return formatter().format(value, ctx); -} - -template >::value)> -auto write(OutputIt out, const T& value) -> typename std::enable_if< - mapped_type_constant>::value == - type::custom_type, - OutputIt>::type { - basic_format_context ctx(out, {}, {}); - return fallback_formatter().format(value, ctx); + typename Context = basic_format_context> +auto write(OutputIt out, const T& value) -> + typename std::enable_if::value == + type::custom_type, + OutputIt>::type { + using formatter_type = + conditional_t::value, + typename Context::template formatter_type, + fallback_formatter>; + Context ctx(out, {}, {}); + return formatter_type().format(value, ctx); } // An argument visitor that formats the argument and writes it via the output