From 538d83fd08443b13d1f65234464392122785f056 Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Wed, 15 Apr 2020 06:28:41 -0700 Subject: [PATCH] Cleanup named arguments --- include/fmt/core.h | 30 ++---------------------------- src/format.cc | 21 +++++++++++++++++++++ 2 files changed, 23 insertions(+), 28 deletions(-) diff --git a/include/fmt/core.h b/include/fmt/core.h index 2a3c1233..359916ce 100644 --- a/include/fmt/core.h +++ b/include/fmt/core.h @@ -767,7 +767,7 @@ template struct named_arg_info { template struct arg_data { - // args_[0] points to named_args_ to avoid bloating format_args. + // args_[0].named_args points to named_args_ to avoid bloating format_args. T args_[1 + (NUM_ARGS != 0 ? NUM_ARGS : 1)]; named_arg_info named_args_[NUM_NAMED_ARGS]; @@ -823,7 +823,7 @@ template constexpr size_t count_named_args() { enum class type { none_type, - named_arg_type, + named_arg_type, // DEPRECATED // Integer types should go first, int_type, uint_type, @@ -854,7 +854,6 @@ struct type_constant : std::integral_constant {}; struct type_constant \ : std::integral_constant {} -FMT_TYPE_CONSTANT(const named_arg_base&, named_arg_type); FMT_TYPE_CONSTANT(int, int_type); FMT_TYPE_CONSTANT(unsigned, uint_type); FMT_TYPE_CONSTANT(long long, long_long_type); @@ -871,12 +870,10 @@ FMT_TYPE_CONSTANT(basic_string_view, string_type); FMT_TYPE_CONSTANT(const void*, pointer_type); FMT_CONSTEXPR bool is_integral_type(type t) { - FMT_ASSERT(t != type::named_arg_type, "invalid argument type"); return t > type::none_type && t <= type::last_integer_type; } FMT_CONSTEXPR bool is_arithmetic_type(type t) { - FMT_ASSERT(t != type::named_arg_type, "invalid argument type"); return t > type::none_type && t <= type::last_numeric_type; } @@ -952,8 +949,6 @@ template class value { fallback_formatter>>; } - value(const named_arg_base& val) { named_arg = &val; } - private: // Formats an argument of a custom type, such as a user-defined class. template @@ -1222,27 +1217,6 @@ FMT_CONSTEXPR auto visit_format_arg(Visitor&& vis, } namespace internal { -// DEPRECATED. -template class arg_map { - private: - struct entry { - basic_string_view name; - basic_format_arg arg; - }; - - entry* map_; - unsigned size_; - - void push_back(value val) { - const auto& named = *val.named_arg; - map_[size_] = {named.name, named.template deserialize()}; - ++size_; - } - - public: - void init(const basic_format_args& args); -}; - // A type-erased reference to an std::locale to avoid heavy include. class locale_ref { private: diff --git a/src/format.cc b/src/format.cc index 3d6da4db..e1f42a2e 100644 --- a/src/format.cc +++ b/src/format.cc @@ -115,6 +115,27 @@ char* sprintf_format(Double value, internal::buffer& buf, return decimal_point_pos; } +// DEPRECATED. +template class arg_map { + private: + struct entry { + basic_string_view name; + basic_format_arg arg; + }; + + entry* map_; + unsigned size_; + + void push_back(value val) { + const auto& named = *val.named_arg; + map_[size_] = {named.name, named.template deserialize()}; + ++size_; + } + + public: + void init(const basic_format_args& args); +}; + // This is deprecated and is kept only to preserve ABI compatibility. template void arg_map::init(const basic_format_args& args) {