From 527e98e3f873562b640377ad8f3c6088ac34e01d Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Sun, 15 Sep 2024 17:28:27 -0700 Subject: [PATCH] Remove unformattable --- include/fmt/base.h | 34 +++++++++++++--------------------- 1 file changed, 13 insertions(+), 21 deletions(-) diff --git a/include/fmt/base.h b/include/fmt/base.h index d2cceb47..ac53e464 100644 --- a/include/fmt/base.h +++ b/include/fmt/base.h @@ -1123,9 +1123,7 @@ constexpr auto has_const_formatter() -> bool { return has_const_formatter_impl(static_cast(nullptr)); } -struct unformattable {}; - -// Maps formatting argument types to a smaller set. Returns unformattable on +// Maps formatting argument types to a smaller set. Returns void on // errors to be SFINAE-friendly. template struct type_mapper { static auto map(signed char) -> int; @@ -1143,16 +1141,14 @@ template struct type_mapper { static auto map(bool) -> bool; template - static auto map(bitint) - -> conditional_t; + static auto map(bitint) -> conditional_t; template static auto map(ubitint) - -> conditional_t; + -> conditional_t; template ::value)> - static auto map(T) -> conditional_t::value || - std::is_same::value, - Char, unformattable>; + static auto map(T) -> conditional_t< + std::is_same::value || std::is_same::value, Char, void>; static auto map(float) -> float; static auto map(double) -> double; @@ -1162,9 +1158,8 @@ template struct type_mapper { static auto map(const Char*) -> const Char*; template , FMT_ENABLE_IF(!std::is_pointer::value)> - static auto map(const T&) - -> conditional_t::value, basic_string_view, - unformattable>; + static auto map(const T&) -> conditional_t::value, + basic_string_view, void>; static auto map(void*) -> const void*; static auto map(const void*) -> const void*; @@ -1173,7 +1168,7 @@ template struct type_mapper { static auto map(std::nullptr_t) -> const void*; template ::value || std::is_member_pointer::value)> - static auto map(const T&) -> unformattable; + static auto map(const T&) -> void; template ::value)> static auto map(const T (&)[N]) -> const T (&)[N]; @@ -1188,8 +1183,7 @@ template struct type_mapper { !std::is_const::value)> {}; template >::value)> - static auto map(T&) - -> conditional_t::value, T&, unformattable>; + static auto map(T&) -> conditional_t::value, T&, void>; template ::value)> static auto map(const T& named_arg) -> decltype(map(named_arg.value)); @@ -2200,7 +2194,7 @@ template class value { private: template FMT_CONSTEXPR value(const T& x, custom_tag) { using value_type = remove_cvref_t; - enum { formattable = !std::is_same::value }; + enum { formattable = !std::is_same::value }; #if defined(__cpp_if_constexpr) if constexpr (!formattable) type_is_unformattable_for _; @@ -2730,11 +2724,9 @@ template struct fstring { template using format_string = typename fstring::t; template -using is_formattable = bool_constant< - !std::is_base_of::value, - detail::unformattable, T>, - Char>>::value>; +using is_formattable = bool_constant::value, int*, T>, Char>, + void>::value>; #ifdef __cpp_concepts template concept formattable = is_formattable, Char>::value;