Simplify has_formatter

This commit is contained in:
Victor Zverovich 2024-09-16 20:08:52 -07:00
parent 0e62e5dc7c
commit 3374a95b50

View File

@ -1108,19 +1108,14 @@ struct use_formatter
!use_format_as<T>::value> {}; !use_format_as<T>::value> {};
template <typename Char, typename T> template <typename Char, typename T>
constexpr auto has_formatter_impl(T*) auto has_formatter_impl(T* p)
-> decltype(formatter<remove_const_t<T>, Char>().format( -> decltype(formatter<remove_const_t<T>, Char>().format(
std::declval<T&>(), *p, std::declval<buffered_context<Char>&>()),
std::declval<buffered_context<Char>&>()), std::true_type());
true) { template <typename Char> auto has_formatter_impl(...) -> std::false_type;
return true;
}
template <typename Char> constexpr auto has_formatter_impl(...) -> bool {
return false;
}
// T can be const-qualified to check if it is const-formattable. // T can be const-qualified to check if it is const-formattable.
template <typename T, typename Char> constexpr auto has_formatter() -> bool { template <typename T, typename Char> constexpr auto has_formatter() -> bool {
return has_formatter_impl<Char>(static_cast<T*>(nullptr)); return decltype(has_formatter_impl<Char>(static_cast<T*>(nullptr)))::value;
} }
template <typename T, typename Char> template <typename T, typename Char>