Remove duplicate error in compile-time checks

This commit is contained in:
Victor Zverovich 2024-09-01 08:34:25 -07:00
parent 64a6c84592
commit 4a55b0d5fd

View File

@ -1475,9 +1475,8 @@ struct has_format_as
#define FMT_MAP_API FMT_CONSTEXPR FMT_ALWAYS_INLINE #define FMT_MAP_API FMT_CONSTEXPR FMT_ALWAYS_INLINE
// Maps formatting arguments to core types. // Maps formatting arguments to reduce the set of types we need to work with.
// arg_mapper reports errors by returning unformattable instead of using // Returns unformattable* on errors to be SFINAE-friendly.
// static_assert because it's used in the is_formattable trait.
template <typename Context> struct arg_mapper { template <typename Context> struct arg_mapper {
using char_type = typename Context::char_type; using char_type = typename Context::char_type;
@ -2843,19 +2842,14 @@ template <typename T, typename Char>
FMT_VISIBILITY("hidden") // Suppress an ld warning on macOS (#3769). FMT_VISIBILITY("hidden") // Suppress an ld warning on macOS (#3769).
FMT_CONSTEXPR auto parse_format_specs(parse_context<Char>& ctx) FMT_CONSTEXPR auto parse_format_specs(parse_context<Char>& ctx)
-> decltype(ctx.begin()) { -> decltype(ctx.begin()) {
using context = buffered_context<Char>; using mapper = arg_mapper<buffered_context<Char>>;
using mapped_type = using mapped = remove_cvref_t<decltype(mapper().map(std::declval<T&>()))>;
remove_cvref_t<decltype(arg_mapper<context>().map(std::declval<T&>()))>;
#if defined(__cpp_if_constexpr) #if defined(__cpp_if_constexpr)
if constexpr (std::is_default_constructible< if constexpr (std::is_default_constructible<formatter<mapped, Char>>())
formatter<mapped_type, Char>>::value) { return formatter<mapped, Char>().parse(ctx);
return formatter<mapped_type, Char>().parse(ctx); return ctx.begin(); // Ignore the error - it is reported by make_format_args.
} else {
type_is_unformattable_for<T, Char> _;
return ctx.begin();
}
#else #else
return formatter<mapped_type, Char>().parse(ctx); return formatter<mapped, Char>().parse(ctx);
#endif #endif
} }