From 4a55b0d5fdfb621b50900bfe81e167c4b9deb210 Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Sun, 1 Sep 2024 08:34:25 -0700 Subject: [PATCH] Remove duplicate error in compile-time checks --- include/fmt/base.h | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/include/fmt/base.h b/include/fmt/base.h index fc9ba1b7..2e82c499 100644 --- a/include/fmt/base.h +++ b/include/fmt/base.h @@ -1475,9 +1475,8 @@ struct has_format_as #define FMT_MAP_API FMT_CONSTEXPR FMT_ALWAYS_INLINE -// Maps formatting arguments to core types. -// arg_mapper reports errors by returning unformattable instead of using -// static_assert because it's used in the is_formattable trait. +// Maps formatting arguments to reduce the set of types we need to work with. +// Returns unformattable* on errors to be SFINAE-friendly. template struct arg_mapper { using char_type = typename Context::char_type; @@ -2843,19 +2842,14 @@ template FMT_VISIBILITY("hidden") // Suppress an ld warning on macOS (#3769). FMT_CONSTEXPR auto parse_format_specs(parse_context& ctx) -> decltype(ctx.begin()) { - using context = buffered_context; - using mapped_type = - remove_cvref_t().map(std::declval()))>; + using mapper = arg_mapper>; + using mapped = remove_cvref_t()))>; #if defined(__cpp_if_constexpr) - if constexpr (std::is_default_constructible< - formatter>::value) { - return formatter().parse(ctx); - } else { - type_is_unformattable_for _; - return ctx.begin(); - } + if constexpr (std::is_default_constructible>()) + return formatter().parse(ctx); + return ctx.begin(); // Ignore the error - it is reported by make_format_args. #else - return formatter().parse(ctx); + return formatter().parse(ctx); #endif }