mirror of
https://github.com/fmtlib/fmt.git
synced 2025-12-07 01:06:53 +08:00
Simplify has_formatter
This commit is contained in:
parent
0e62e5dc7c
commit
3374a95b50
@ -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>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user