Fix #2816: strip named argument wrappers for compile-time checking

This commit is contained in:
timsong-cpp
2022-03-17 23:53:48 -05:00
committed by Victor Zverovich
parent c076a54a4d
commit 3d19be282a
2 changed files with 13 additions and 1 deletions

View File

@@ -2647,6 +2647,14 @@ FMT_CONSTEXPR FMT_INLINE void parse_format_string(
}
}
template <typename T, bool = is_named_arg<T>::value> struct strip_named_arg {
using type = T;
};
template <typename T> struct strip_named_arg<T, true> {
using type = remove_cvref_t<decltype(T::value)>;
};
template <typename T, typename ParseContext>
FMT_CONSTEXPR auto parse_format_specs(ParseContext& ctx)
-> decltype(ctx.begin()) {
@@ -2654,7 +2662,8 @@ FMT_CONSTEXPR auto parse_format_specs(ParseContext& ctx)
using context = buffer_context<char_type>;
using mapped_type = conditional_t<
mapped_type_constant<T, context>::value != type::custom_type,
decltype(arg_mapper<context>().map(std::declval<const T&>())), T>;
decltype(arg_mapper<context>().map(std::declval<const T&>())),
typename strip_named_arg<T>::type>;
auto f = conditional_t<has_formatter<mapped_type, context>::value,
formatter<mapped_type, char_type>,
fallback_formatter<T, char_type>>();