From 3374a95b50bb6bb429e630b3931640311b54fea8 Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Mon, 16 Sep 2024 20:08:52 -0700 Subject: [PATCH] Simplify has_formatter --- include/fmt/base.h | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/include/fmt/base.h b/include/fmt/base.h index 80a31442..16dc37ad 100644 --- a/include/fmt/base.h +++ b/include/fmt/base.h @@ -1108,19 +1108,14 @@ struct use_formatter !use_format_as::value> {}; template -constexpr auto has_formatter_impl(T*) +auto has_formatter_impl(T* p) -> decltype(formatter, Char>().format( - std::declval(), - std::declval&>()), - true) { - return true; -} -template constexpr auto has_formatter_impl(...) -> bool { - return false; -} + *p, std::declval&>()), + std::true_type()); +template auto has_formatter_impl(...) -> std::false_type; // T can be const-qualified to check if it is const-formattable. template constexpr auto has_formatter() -> bool { - return has_formatter_impl(static_cast(nullptr)); + return decltype(has_formatter_impl(static_cast(nullptr)))::value; } template