diff --git a/include/fmt/core.h b/include/fmt/core.h index db7649b2..235d7657 100644 --- a/include/fmt/core.h +++ b/include/fmt/core.h @@ -1451,24 +1451,18 @@ FMT_CONSTEXPR basic_format_arg make_arg(const T& value) { return arg; } -template int check(unformattable) { - static_assert( - formattable(), - "Cannot format an argument. To make type T formattable provide a " - "formatter specialization: https://fmt.dev/latest/api.html#udt"); - return 0; -} -template constexpr const U& check(const U& val) { - return val; -} - // The type template parameter is there to avoid an ODR violation when using // a fallback formatter in one translation unit and an implicit conversion in // another (not recommended). template -constexpr value make_arg(const T& val) { - return detail::check(arg_mapper().map(val)); +FMT_CONSTEXPR value make_arg(const T& val) { + const auto& arg = arg_mapper().map(val); + static_assert( + !std::is_same::value, + "Cannot format an argument. To make type T formattable provide a " + "formatter specialization: https://fmt.dev/latest/api.html#udt"); + return arg; } template