From 1b23e25f9568208f7b5d3a99b2910171dcb98512 Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Sat, 27 Mar 2021 18:57:18 -0700 Subject: [PATCH] Simplify formattability check --- include/fmt/core.h | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) 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