From 5b706bb7b574527fde8b2ec1cd9fa9b9ddd932b8 Mon Sep 17 00:00:00 2001 From: Christian Mazakas Date: Fri, 27 Jan 2023 14:41:48 -0800 Subject: [PATCH] Update node-based foa containers to default their element_type default constructor and delete the copy constructor to get the appropriate type-based optimizations --- include/boost/unordered/unordered_node_map.hpp | 10 +++++----- include/boost/unordered/unordered_node_set.hpp | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/include/boost/unordered/unordered_node_map.hpp b/include/boost/unordered/unordered_node_map.hpp index 46835fde..ca6f7046 100644 --- a/include/boost/unordered/unordered_node_map.hpp +++ b/include/boost/unordered/unordered_node_map.hpp @@ -48,15 +48,15 @@ namespace boost { value_type* p; /* - * we use a defined copy constructor here so the type is no longer + * we use a deleted copy constructor here so the type is no longer * trivially copy-constructible which inhibits our memcpy * optimizations when copying the tables */ - element_type() : p(nullptr) {} - element_type(element_type const& rhs) : p(rhs.p) {} + element_type() = default; + element_type(element_type const&) = delete; }; - static value_type& value_from(element_type x) { return *(x.p); } + static value_type& value_from(element_type const& x) { return *(x.p); } template static raw_key_type const& extract(std::pair const& kv) @@ -64,7 +64,7 @@ namespace boost { return kv.first; } - static raw_key_type const& extract(element_type kv) + static raw_key_type const& extract(element_type const& kv) { return kv.p->first; } diff --git a/include/boost/unordered/unordered_node_set.hpp b/include/boost/unordered/unordered_node_set.hpp index cb2b7988..6733913c 100644 --- a/include/boost/unordered/unordered_node_set.hpp +++ b/include/boost/unordered/unordered_node_set.hpp @@ -45,16 +45,16 @@ namespace boost { value_type* p; /* - * we use a defined copy constructor here so the type is no longer + * we use a deleted copy constructor here so the type is no longer * trivially copy-constructible which inhibits our memcpy * optimizations when copying the tables */ - element_type() : p(nullptr) {} - element_type(element_type const& rhs) : p(rhs.p) {} + element_type() = default; + element_type(element_type const&) = delete; }; - static value_type& value_from(element_type x) { return *x.p; } - static Key const& extract(element_type k) { return *k.p; } + static value_type& value_from(element_type const& x) { return *x.p; } + static Key const& extract(element_type const& k) { return *k.p; } static element_type&& move(element_type& x) { return std::move(x); } static value_type&& move(value_type& x) { return std::move(x); }