From 026f99178ef0698041c34493d344eafcfd7bbe3d Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Mon, 16 Mar 2020 19:10:41 -0700 Subject: [PATCH] Simplify dynamic store --- include/fmt/core.h | 35 +++++++++-------------------------- 1 file changed, 9 insertions(+), 26 deletions(-) diff --git a/include/fmt/core.h b/include/fmt/core.h index 8dc770b4..f58f512b 100644 --- a/include/fmt/core.h +++ b/include/fmt/core.h @@ -1206,14 +1206,6 @@ inline basic_format_arg make_arg(const T& value) { return make_arg(value); } -template struct is_string_view : std::false_type {}; - -template -struct is_string_view, Char> : std::true_type {}; - -template -struct is_string_view, Char> : std::true_type {}; - template struct is_reference_wrapper : std::false_type {}; template @@ -1233,31 +1225,21 @@ class dyn_arg_storage { T value; template - FMT_CONSTEXPR storage_node(const Arg& arg, owning_ptr&& next) : value(arg) { - this->next = std::move(next); // Must be initialised after value. - } + FMT_CONSTEXPR storage_node(const Arg& arg) : value(arg) {} template - FMT_CONSTEXPR storage_node(const basic_string_view& arg, - owning_ptr&& next) - : value(arg.data(), arg.size()) { - this->next = std::move(next); // Must be initialised after value. - } + FMT_CONSTEXPR storage_node(const basic_string_view& arg) + : value(arg.data(), arg.size()) {} }; - storage_node_base<>::owning_ptr head_{nullptr}; + storage_node_base<>::owning_ptr head_; public: - dyn_arg_storage() = default; - dyn_arg_storage(const dyn_arg_storage&) = delete; - dyn_arg_storage(dyn_arg_storage&&) = default; - - dyn_arg_storage& operator=(const dyn_arg_storage&) = delete; - dyn_arg_storage& operator=(dyn_arg_storage&&) = default; - template const T& push(const Arg& arg) { - auto node = new storage_node(arg, std::move(head_)); + auto next = std::move(head_); + auto node = new storage_node(arg); head_.reset(node); + head_->next = std::move(next); return node->value; } }; @@ -1396,7 +1378,8 @@ class dynamic_format_arg_store using type = std::integral_constant< bool, !(internal::is_reference_wrapper::value || - internal::is_string_view::value || + std::is_same>::value || + std::is_same>::value || (mapped_type != internal::type::cstring_type && mapped_type != internal::type::string_type && mapped_type != internal::type::custom_type &&