From 904e806b1ec80d4ddc24145d7243894955f76bb5 Mon Sep 17 00:00:00 2001 From: Christian Mazakas Date: Tue, 10 Jan 2023 15:18:46 -0800 Subject: [PATCH] Update node containers to no longer memcpy their pointer arrays --- include/boost/unordered/detail/foa.hpp | 4 ++-- include/boost/unordered/unordered_node_map.hpp | 3 +++ include/boost/unordered/unordered_node_set.hpp | 8 +++++--- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/include/boost/unordered/detail/foa.hpp b/include/boost/unordered/detail/foa.hpp index 3c84ea3b..5cc61a60 100644 --- a/include/boost/unordered/detail/foa.hpp +++ b/include/boost/unordered/detail/foa.hpp @@ -1668,9 +1668,9 @@ private: bool, #if BOOST_WORKAROUND(BOOST_LIBSTDCXX_VERSION,<50000) /* std::is_trivially_copy_constructible not provided */ - boost::has_trivial_copy::value + boost::has_trivial_copy::value #else - std::is_trivially_copy_constructible::value + std::is_trivially_copy_constructible::value #endif &&( is_std_allocator::value|| diff --git a/include/boost/unordered/unordered_node_map.hpp b/include/boost/unordered/unordered_node_map.hpp index 61a2223a..d31b824e 100644 --- a/include/boost/unordered/unordered_node_map.hpp +++ b/include/boost/unordered/unordered_node_map.hpp @@ -45,6 +45,9 @@ namespace boost { struct element_type { value_type* p; + + element_type() : p(nullptr) {} + element_type(element_type const& rhs) : p(rhs.p) {} }; static value_type& value_from(element_type x) { return *(x.p); } diff --git a/include/boost/unordered/unordered_node_set.hpp b/include/boost/unordered/unordered_node_set.hpp index 0387bdf6..56325162 100644 --- a/include/boost/unordered/unordered_node_set.hpp +++ b/include/boost/unordered/unordered_node_set.hpp @@ -16,7 +16,6 @@ #include #include -#include #include #include @@ -41,9 +40,9 @@ namespace boost { static Key const& extract(value_type const& key) { return key; } -#if 1 +#if 0 using element_type = value_type*; - static value_type& value_from(element_type x) { return *x; } + static value_type& value_from(element_type& x) { return *x; } static Key const& extract(element_type k) { return *k; } static element_type&& move(element_type& x) { return std::move(x); } @@ -99,6 +98,9 @@ namespace boost { struct element_type { value_type* p; + + element_type() : p(nullptr) {} + element_type(element_type const& rhs) : p(rhs.p) {} }; static value_type& value_from(element_type x) { return *x.p; }