From b57b51b036971e761040554e76a012c403be0591 Mon Sep 17 00:00:00 2001 From: Christian Mazakas Date: Thu, 12 Jan 2023 10:52:03 -0800 Subject: [PATCH] Remove moved_value_from() in favor of overloading move() in container type traits --- include/boost/unordered/detail/foa.hpp | 4 ++-- include/boost/unordered/unordered_flat_map.hpp | 5 ----- include/boost/unordered/unordered_flat_set.hpp | 7 +------ include/boost/unordered/unordered_node_map.hpp | 13 ++++++------- include/boost/unordered/unordered_node_set.hpp | 6 +----- 5 files changed, 10 insertions(+), 25 deletions(-) diff --git a/include/boost/unordered/detail/foa.hpp b/include/boost/unordered/detail/foa.hpp index 58376dc2..f55c99b0 100644 --- a/include/boost/unordered/detail/foa.hpp +++ b/include/boost/unordered/detail/foa.hpp @@ -1255,7 +1255,7 @@ public: * elements' values. */ x.for_all_elements([this](element_type* p){ - unchecked_insert(type_policy::moved_value_from(*p)); + unchecked_insert(type_policy::move(type_policy::value_from(*p))); }); } } @@ -1352,7 +1352,7 @@ public: * elements' values. */ x.for_all_elements([this](element_type* p){ - unchecked_insert(type_policy::moved_value_from(*p)); + unchecked_insert(type_policy::move(type_policy::value_from(*p))); }); } } diff --git a/include/boost/unordered/unordered_flat_map.hpp b/include/boost/unordered/unordered_flat_map.hpp index c9b9f544..7ceebc40 100644 --- a/include/boost/unordered/unordered_flat_map.hpp +++ b/include/boost/unordered/unordered_flat_map.hpp @@ -60,11 +60,6 @@ namespace boost { std::move(const_cast(x.second))}; } - static moved_type moved_value_from(element_type& x) - { - return move(x); - } - template static void construct(A& al, element_type* p, moved_type&& x) { diff --git a/include/boost/unordered/unordered_flat_set.hpp b/include/boost/unordered/unordered_flat_set.hpp index b2b91db5..d88c582c 100644 --- a/include/boost/unordered/unordered_flat_set.hpp +++ b/include/boost/unordered/unordered_flat_set.hpp @@ -41,15 +41,10 @@ namespace boost { using element_type = value_type; - static Key const& value_from(element_type const& x) { return x; } + static Key& value_from(element_type& x) { return x; } static element_type&& move(element_type& x) { return std::move(x); } - static element_type&& moved_value_from(element_type& x) - { - return move(x); - } - template static void construct(A& al, element_type* p, element_type const& copy) { diff --git a/include/boost/unordered/unordered_node_map.hpp b/include/boost/unordered/unordered_node_map.hpp index 85e7bab1..849469b1 100644 --- a/include/boost/unordered/unordered_node_map.hpp +++ b/include/boost/unordered/unordered_node_map.hpp @@ -41,6 +41,7 @@ namespace boost { using init_type = std::pair; using value_type = std::pair; + using moved_type = std::pair; struct element_type { @@ -57,13 +58,6 @@ namespace boost { static value_type& value_from(element_type x) { return *(x.p); } - static std::pair moved_value_from( - element_type& x) - { - return {std::move(const_cast(x.p->first)), - std::move(const_cast(x.p->second))}; - } - template static raw_key_type const& extract(std::pair const& kv) { @@ -76,6 +70,11 @@ namespace boost { } static element_type&& move(element_type& x) { return std::move(x); } + static moved_type move(value_type& x) + { + return {std::move(const_cast(x.first)), + std::move(const_cast(x.second))}; + } template static void construct(A&, element_type* p, element_type&& x) diff --git a/include/boost/unordered/unordered_node_set.hpp b/include/boost/unordered/unordered_node_set.hpp index 4a9b5b12..cb2b7988 100644 --- a/include/boost/unordered/unordered_node_set.hpp +++ b/include/boost/unordered/unordered_node_set.hpp @@ -56,11 +56,7 @@ namespace boost { static value_type& value_from(element_type x) { return *x.p; } static Key const& extract(element_type k) { return *k.p; } static element_type&& move(element_type& x) { return std::move(x); } - - static value_type&& moved_value_from(element_type& x) - { - return std::move(*x.p); - } + static value_type&& move(value_type& x) { return std::move(x); } template static void construct(A& al, element_type* p, element_type const& copy)