diff --git a/include/fmt/base.h b/include/fmt/base.h index 2e82c499..401cbd12 100644 --- a/include/fmt/base.h +++ b/include/fmt/base.h @@ -1473,7 +1473,7 @@ template struct has_format_as : bool_constant, void>::value> {}; -#define FMT_MAP_API FMT_CONSTEXPR FMT_ALWAYS_INLINE +#define FMT_MAP_API static FMT_CONSTEXPR FMT_ALWAYS_INLINE // Maps formatting arguments to reduce the set of types we need to work with. // Returns unformattable* on errors to be SFINAE-friendly. @@ -1615,7 +1615,7 @@ template struct arg_mapper { // A type constant after applying arg_mapper. template using mapped_type_constant = - type_constant().map(std::declval())), + type_constant::map(std::declval())), typename Context::char_type>; template FMT_CONSTEXPR auto make_arg(T& val) -> value { - using arg_type = remove_cvref_t().map(val))>; + using arg_type = remove_cvref_t::map(val))>; // Use enum instead of constexpr because the latter may generate code. enum { @@ -1725,7 +1725,7 @@ FMT_CONSTEXPR auto make_arg(T& val) -> value { formattable, "Cannot format an argument. To make type T formattable provide a " "formatter specialization: https://fmt.dev/latest/api.html#udt"); - return {arg_mapper().map(val)}; + return {arg_mapper::map(val)}; } template @@ -1783,7 +1783,7 @@ struct format_arg_store { named_arg_info named_args[NUM_NAMED_ARGS]; template - FMT_MAP_API format_arg_store(T&... values) + FMT_CONSTEXPR FMT_ALWAYS_INLINE format_arg_store(T&... values) : args{{named_args, NUM_NAMED_ARGS}, make_arg(values)...} { using dummy = int[]; @@ -2088,9 +2088,10 @@ template using buffered_context = basic_format_context, Char>; template -using is_formattable = bool_constant>() - .map(std::declval()))>::value>; +using is_formattable = bool_constant< + !std::is_base_of>::map( + std::declval()))>::value>; #if FMT_USE_CONCEPTS template @@ -2843,13 +2844,13 @@ FMT_VISIBILITY("hidden") // Suppress an ld warning on macOS (#3769). FMT_CONSTEXPR auto parse_format_specs(parse_context& ctx) -> decltype(ctx.begin()) { using mapper = arg_mapper>; - using mapped = remove_cvref_t()))>; + using mapped_type = remove_cvref_t()))>; #if defined(__cpp_if_constexpr) - if constexpr (std::is_default_constructible>()) - return formatter().parse(ctx); - return ctx.begin(); // Ignore the error - it is reported by make_format_args. + 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 } diff --git a/include/fmt/format.h b/include/fmt/format.h index 3a69d659..fe592fb7 100644 --- a/include/fmt/format.h +++ b/include/fmt/format.h @@ -1081,7 +1081,7 @@ class loc_value { template ::value)> loc_value(T value) { value_.type_ = detail::mapped_type_constant::value; - value_.value_ = detail::arg_mapper().map(value); + value_.value_ = detail::arg_mapper::map(value); } template ::value)> @@ -3648,10 +3648,10 @@ template enable_if_t< std::is_class::value && !has_to_string_view::value && !is_floating_point::value && !std::is_same::value && - !std::is_same().map( - value))>>::value, + !std::is_same::map(value))>>::value, OutputIt> { - return write(out, arg_mapper().map(value)); + return write(out, arg_mapper::map(value)); } template struct range_mapper { } template , Context>::value)> - static auto map(T&& value) - -> decltype(mapper().map(static_cast(value))) { - return mapper().map(static_cast(value)); + static auto map(T&& value) -> decltype(mapper::map(static_cast(value))) { + return mapper::map(static_cast(value)); } };