From 63479c8519c7fa3571707ec7f40b87438b9b9c51 Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Mon, 20 Apr 2020 17:24:43 -0700 Subject: [PATCH] Use a delegating ctor and add inlines --- include/fmt/core.h | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/include/fmt/core.h b/include/fmt/core.h index 3fc11afb..e301f1f5 100644 --- a/include/fmt/core.h +++ b/include/fmt/core.h @@ -1566,8 +1566,11 @@ template class basic_format_args { friend class internal::arg_map; - void set_data(const internal::value* values) { values_ = values; } - void set_data(const format_arg* args) { args_ = args; } + basic_format_args(unsigned long long desc, + const internal::value* values) + : desc_(desc), values_(values) {} + basic_format_args(unsigned long long desc, const format_arg* args) + : desc_(desc), args_(args) {} format_arg do_get(int index) const { format_arg arg; @@ -1591,10 +1594,8 @@ template class basic_format_args { \endrst */ template - basic_format_args(const format_arg_store& store) - : desc_(store.desc) { - set_data(store.data_.args()); - } + FMT_INLINE basic_format_args(const format_arg_store& store) + : basic_format_args(store.desc, store.data_.args()) {} /** \rst @@ -1602,10 +1603,8 @@ template class basic_format_args { `~fmt::dynamic_format_arg_store`. \endrst */ - basic_format_args(const dynamic_format_arg_store& store) - : desc_(store.get_types()) { - set_data(store.data_.data()); - } + FMT_INLINE basic_format_args(const dynamic_format_arg_store& store) + : basic_format_args(store.get_types(), store.data_.data()) {} /** \rst @@ -1613,9 +1612,8 @@ template class basic_format_args { \endrst */ basic_format_args(const format_arg* args, int count) - : desc_(internal::is_unpacked_bit | internal::to_unsigned(count)) { - set_data(args); - } + : basic_format_args( + internal::is_unpacked_bit | internal::to_unsigned(count), args) {} /** Returns the argument with the specified id. */ format_arg get(int id) const { @@ -1645,7 +1643,8 @@ template class basic_format_args { /** An alias to ``basic_format_args``. */ // It is a separate type rather than an alias to make symbols readable. struct format_args : basic_format_args { - using basic_format_args::basic_format_args; + template + FMT_INLINE format_args(const Args&... args) : basic_format_args(args...) {} }; struct wformat_args : basic_format_args { using basic_format_args::basic_format_args; @@ -1693,7 +1692,7 @@ struct named_arg : view, named_arg_base { }; template ::value)> -inline void check_format_string(const S&) { +FMT_INLINE void check_format_string(const S&) { #ifdef FMT_ENFORCE_COMPILE_STRING static_assert(is_compile_string::value, "FMT_ENFORCE_COMPILE_STRING requires all format strings to "