diff --git a/include/fmt/args.h b/include/fmt/args.h index 31a60e8f..7a0f3e07 100644 --- a/include/fmt/args.h +++ b/include/fmt/args.h @@ -84,7 +84,7 @@ class dynamic_format_arg_store template struct need_copy { static constexpr detail::type mapped_type = - detail::mapped_type_constant::value; + detail::mapped_type_constant::value; enum { value = !(detail::is_reference_wrapper::value || diff --git a/include/fmt/base.h b/include/fmt/base.h index 9a440365..cbc6d6b4 100644 --- a/include/fmt/base.h +++ b/include/fmt/base.h @@ -1028,14 +1028,12 @@ template using mapped_t = decltype(detail::arg_mapper::map(std::declval())); // A type constant after applying arg_mapper. -template -using mapped_type_constant = - type_constant::map( - std::declval())), - typename Context::char_type>; +template +using mapped_type_constant = type_constant, Char>; template ::value> + type TYPE = + mapped_type_constant::value> using stored_type_constant = std::integral_constant< type, Context::builtin_types || TYPE == type::int_type ? TYPE : type::custom_type>; @@ -1801,7 +1799,7 @@ class format_string_checker { template explicit FMT_CONSTEXPR format_string_checker(basic_string_view fmt, arg_pack) - : types_{mapped_type_constant>::value...}, + : types_{mapped_type_constant::value...}, named_args_{}, context_(fmt, NUM_ARGS, types_), parse_funcs_{&invoke_parse...} { @@ -2790,8 +2788,8 @@ template struct native_formatter { }; template -struct locking : bool_constant::value == - type::custom_type> {}; +struct locking + : bool_constant::value == type::custom_type> {}; template struct locking>::nonlocking>> : std::false_type {}; diff --git a/include/fmt/format.h b/include/fmt/format.h index 884d2c6d..040e3058 100644 --- a/include/fmt/format.h +++ b/include/fmt/format.h @@ -1084,7 +1084,7 @@ class loc_value { public: template ::value)> loc_value(T value) { - value_.type_ = detail::mapped_type_constant::value; + value_.type_ = detail::mapped_type_constant::value; value_.value_ = detail::arg_mapper::map(value); } @@ -3606,10 +3606,8 @@ constexpr auto write(OutputIt out, const T& value) -> OutputIt { // FMT_ENABLE_IF() condition separated to workaround an MSVC bug. template < typename Char, typename OutputIt, typename T, - bool check = - std::is_enum::value && !std::is_same::value && - mapped_type_constant>::value != - type::custom_type, + bool check = std::is_enum::value && !std::is_same::value && + mapped_type_constant::value != type::custom_type, FMT_ENABLE_IF(check)> FMT_CONSTEXPR auto write(OutputIt out, T value) -> OutputIt { return write(out, static_cast>(value)); @@ -3659,17 +3657,15 @@ FMT_CONSTEXPR auto write(OutputIt out, const T& value) -> enable_if_t< } template > -FMT_CONSTEXPR auto write(OutputIt out, const T& value) - -> enable_if_t::value == - type::custom_type && - !std::is_fundamental::value, - OutputIt> { - auto formatter = typename Context::template formatter_type(); - auto parse_ctx = typename Context::parse_context_type({}); - formatter.parse(parse_ctx); - auto ctx = Context(out, {}, {}); - return formatter.format(value, ctx); + FMT_ENABLE_IF(mapped_type_constant::value == + type::custom_type && + !std::is_fundamental::value)> +FMT_CONSTEXPR auto write(OutputIt out, const T& value) -> OutputIt { + auto f = formatter(); + auto parse_ctx = parse_context({}); + f.parse(parse_ctx); + auto ctx = basic_format_context(out, {}, {}); + return f.format(value, ctx); } template