diff --git a/include/fmt/base.h b/include/fmt/base.h index efda6db5..50b6c97b 100644 --- a/include/fmt/base.h +++ b/include/fmt/base.h @@ -2240,9 +2240,9 @@ template struct named_arg_value { }; template struct custom_value { - using parse_context = typename Context::parse_context_type; + using char_type = typename Context::char_type; void* value; - void (*format)(void* arg, parse_context& parse_ctx, Context& ctx); + void (*format)(void* arg, parse_context& parse_ctx, Context& ctx); }; enum class custom_tag {}; @@ -2600,9 +2600,6 @@ template class basic_format_arg { auto type() const -> detail::type { return type_; } auto is_integral() const -> bool { return detail::is_integral_type(type_); } - auto is_arithmetic() const -> bool { - return detail::is_arithmetic_type(type_); - } /** * Visits an argument dispatching to the appropriate visit method based on @@ -2650,8 +2647,8 @@ template class basic_format_arg { } auto format_custom(const char_type* parse_begin, - typename Context::parse_context_type& parse_ctx, - Context& ctx) -> bool { + parse_context& parse_ctx, Context& ctx) + -> bool { if (type_ != detail::type::custom_type) return false; parse_ctx.advance_to(parse_begin); value_.custom.format(value_.custom.value, parse_ctx, ctx); @@ -2659,12 +2656,6 @@ template class basic_format_arg { } }; -template -FMT_DEPRECATED FMT_CONSTEXPR auto visit_format_arg( - Visitor&& vis, const basic_format_arg& arg) -> decltype(vis(0)) { - return arg.visit(static_cast(vis)); -} - /** * A view of a collection of formatting arguments. To avoid lifetime issues it * should only be used as a parameter type in type-erased functions such as @@ -2674,10 +2665,6 @@ FMT_DEPRECATED FMT_CONSTEXPR auto visit_format_arg( * fmt::format_args args = fmt::make_format_args(); // Dangling reference */ template class basic_format_args { - public: - using size_type = int; - using format_arg = basic_format_arg; - private: // A descriptor that contains information about formatting arguments. // If the number of arguments is less or equal to max_packed_args then @@ -2691,7 +2678,7 @@ template class basic_format_args { // may require more code (at least on x86-64) even if the same amount of // data is actually copied to stack. It saves ~10% on the bloat test. const detail::value* values_; - const format_arg* args_; + const basic_format_arg* args_; }; constexpr auto is_packed() const -> bool { @@ -2708,6 +2695,8 @@ template class basic_format_args { } public: + using format_arg = basic_format_arg; + constexpr basic_format_args() : desc_(0), args_(nullptr) {} /// Constructs a `basic_format_args` object from `format_arg_store`. @@ -2775,7 +2764,7 @@ template class basic_format_args { class context { private: appender out_; - basic_format_args args_; + format_args args_; FMT_NO_UNIQUE_ADDRESS detail::locale_ref loc_; public: @@ -2784,15 +2773,14 @@ class context { using iterator = appender; using format_arg = basic_format_arg; - using parse_context_type = parse_context; + using parse_context_type FMT_DEPRECATED = parse_context<>; template using formatter_type FMT_DEPRECATED = formatter; enum { builtin_types = FMT_BUILTIN_TYPES }; /// Constructs a `context` object. References to the arguments are stored /// in the object so make sure they have appropriate lifetimes. - FMT_CONSTEXPR context(iterator out, basic_format_args ctx_args, - detail::locale_ref loc = {}) - : out_(out), args_(ctx_args), loc_(loc) {} + FMT_CONSTEXPR context(iterator out, format_args a, detail::locale_ref l = {}) + : out_(out), args_(a), loc_(l) {} context(context&&) = default; context(const context&) = delete; void operator=(const context&) = delete; @@ -2802,7 +2790,6 @@ class context { FMT_CONSTEXPR auto arg_id(string_view name) -> int { return args_.get_id(name); } - auto args() const -> const basic_format_args& { return args_; } // Returns an iterator to the beginning of the output range. FMT_CONSTEXPR auto out() -> iterator { return out_; } @@ -2887,6 +2874,9 @@ template concept formattable = is_formattable, Char>::value; #endif +template +using has_formatter FMT_DEPRECATED = std::is_constructible>; + // A formatter specialization for natively supported types. template struct formatter class generic_context { public: using char_type = Char; using iterator = OutputIt; - using parse_context_type = parse_context; - template using formatter_type = formatter; + using parse_context_type FMT_DEPRECATED = parse_context; + template + using formatter_type FMT_DEPRECATED = formatter; enum { builtin_types = FMT_BUILTIN_TYPES }; constexpr generic_context(OutputIt out, @@ -1064,9 +1065,6 @@ template class generic_context { FMT_CONSTEXPR auto arg_id(basic_string_view name) -> int { return args_.get_id(name); } - auto args() const -> const basic_format_args& { - return args_; - } FMT_CONSTEXPR auto out() -> iterator { return out_; } diff --git a/include/fmt/printf.h b/include/fmt/printf.h index 7eccc0a7..4cd5411b 100644 --- a/include/fmt/printf.h +++ b/include/fmt/printf.h @@ -505,7 +505,7 @@ void vprintf(buffer& buf, basic_string_view format, } if (specs.alt() && arg.visit(is_zero_int())) specs.clear_alt(); if (specs.fill_unit() == '0') { - if (arg.is_arithmetic() && specs.align() != align::left) { + if (is_arithmetic_type(arg.type()) && specs.align() != align::left) { specs.set_align(align::numeric); } else { // Ignore '0' flag for non-numeric types or if '-' flag is also present. diff --git a/include/fmt/ranges.h b/include/fmt/ranges.h index 900fc9dc..8fdffaed 100644 --- a/include/fmt/ranges.h +++ b/include/fmt/ranges.h @@ -359,20 +359,19 @@ template struct is_range { namespace detail { -template -using has_formatter = std::is_constructible>; - template struct range_mapper { using mapper = arg_mapper; using char_type = typename Context::char_type; template , char_type>::value)> + FMT_ENABLE_IF(std::is_constructible< + formatter, char_type>>::value)> static auto map(T&& value) -> T&& { return static_cast(value); } template , char_type>::value)> + FMT_ENABLE_IF(!std::is_constructible< + formatter, char_type>>::value)> static auto map(T&& value) -> decltype(mapper::map(static_cast(value))) { return mapper::map(static_cast(value)); }