From 32544b61084c7bf6f44741978118403d85cef41d Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Tue, 11 Jun 2019 19:22:19 -0700 Subject: [PATCH] More cleanup --- include/fmt/core.h | 20 +++++++------------- include/fmt/format.h | 7 +++++++ 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/include/fmt/core.h b/include/fmt/core.h index ececfc9a..443e918d 100644 --- a/include/fmt/core.h +++ b/include/fmt/core.h @@ -1094,9 +1094,10 @@ template class format_arg_store { friend class basic_format_args; public: - static constexpr unsigned long long TYPES = + static constexpr unsigned long long types = is_packed ? internal::encode_types() : internal::is_unpacked_bit | num_args; + FMT_DEPRECATED static constexpr unsigned long long TYPES = types; format_arg_store(const Args&... args) : data_{internal::make_arg(args)...} {} @@ -1173,7 +1174,7 @@ template class basic_format_args { */ template basic_format_args(const format_arg_store& store) - : types_(static_cast(store.TYPES)) { + : types_(static_cast(store.types)) { set_data(store.data_); } @@ -1206,23 +1207,16 @@ template class basic_format_args { // It is a separate type rather than an alias to make symbols readable. struct format_args : basic_format_args { template - format_args(Args&&... arg) - : basic_format_args(std::forward(arg)...) {} + format_args(Args&&... args) + : basic_format_args(std::forward(args)...) {} }; struct wformat_args : basic_format_args { template - wformat_args(Args&&... arg) - : basic_format_args(std::forward(arg)...) {} + wformat_args(Args&&... args) + : basic_format_args(std::forward(args)...) {} }; namespace internal { -template -FMT_CONSTEXPR typename Context::format_arg get_arg(Context& ctx, unsigned id) { - auto arg = ctx.arg(id); - if (!arg) ctx.on_error("argument index out of range"); - return arg; -} - template struct named_arg_base { basic_string_view name; diff --git a/include/fmt/format.h b/include/fmt/format.h index 1c257b1d..f3bd1111 100644 --- a/include/fmt/format.h +++ b/include/fmt/format.h @@ -1737,6 +1737,13 @@ FMT_CONSTEXPR void set_dynamic_spec(T& value, FormatArg arg, ErrorHandler eh) { struct auto_id {}; +template +FMT_CONSTEXPR typename Context::format_arg get_arg(Context& ctx, unsigned id) { + auto arg = ctx.arg(id); + if (!arg) ctx.on_error("argument index out of range"); + return arg; +} + // The standard format specifier handler with checking. template class specs_handler : public specs_setter {