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