From 6932a2d571fc304ae1c1eaa4cc3a6369444d3672 Mon Sep 17 00:00:00 2001 From: Daniel James Date: Sun, 8 Jul 2012 11:55:57 +0000 Subject: [PATCH] Unordered: Fix using a C++03 allocator with C++11 compiler. Because the nodes had an implicit constructor, the `has_construct` traits was detecting that the nodes could be constructed by construction then copy, which really wasn't wanted. Also add a check that nodes aren't been copy constructed to make sure this doesn't happen again. Refs #7100. [SVN r79358] --- include/boost/unordered/detail/equivalent.hpp | 18 ++++++++++++++++-- include/boost/unordered/detail/unique.hpp | 18 ++++++++++++++++-- 2 files changed, 32 insertions(+), 4 deletions(-) diff --git a/include/boost/unordered/detail/equivalent.hpp b/include/boost/unordered/detail/equivalent.hpp index 74a4205a..5cbf6a7c 100644 --- a/include/boost/unordered/detail/equivalent.hpp +++ b/include/boost/unordered/detail/equivalent.hpp @@ -37,7 +37,7 @@ namespace boost { namespace unordered { namespace detail { #if BOOST_UNORDERED_DETAIL_FULL_CONSTRUCT template - grouped_node(BOOST_UNORDERED_EMPLACE_ARGS) : + explicit grouped_node(BOOST_UNORDERED_EMPLACE_ARGS) : node_base(), group_prev_(), hash_(0) @@ -49,6 +49,10 @@ namespace boost { namespace unordered { namespace detail { ~grouped_node() { boost::unordered::detail::destroy(this->value_ptr()); } + + grouped_node(grouped_node const&) { + assert(false); + } #else grouped_node() : node_base(), @@ -61,6 +65,9 @@ namespace boost { namespace unordered { namespace detail { { group_prev_ = self; } + + private: + grouped_node& operator=(grouped_node const&); }; template @@ -77,7 +84,7 @@ namespace boost { namespace unordered { namespace detail { #if BOOST_UNORDERED_DETAIL_FULL_CONSTRUCT template - grouped_ptr_node(BOOST_UNORDERED_EMPLACE_ARGS) : + explicit grouped_ptr_node(BOOST_UNORDERED_EMPLACE_ARGS) : bucket_base(), group_prev_(0), hash_(0) @@ -89,6 +96,10 @@ namespace boost { namespace unordered { namespace detail { ~grouped_ptr_node() { boost::unordered::detail::destroy(this->value_ptr()); } + + grouped_ptr_node(grouped_ptr_node const&) { + assert(false); + } #else grouped_ptr_node() : bucket_base(), @@ -101,6 +112,9 @@ namespace boost { namespace unordered { namespace detail { { group_prev_ = self; } + + private: + grouped_ptr_node& operator=(grouped_ptr_node const&); }; // If the allocator uses raw pointers use grouped_ptr_node diff --git a/include/boost/unordered/detail/unique.hpp b/include/boost/unordered/detail/unique.hpp index e7777183..10db58fa 100644 --- a/include/boost/unordered/detail/unique.hpp +++ b/include/boost/unordered/detail/unique.hpp @@ -38,7 +38,7 @@ namespace boost { namespace unordered { namespace detail { #if BOOST_UNORDERED_DETAIL_FULL_CONSTRUCT template - unique_node(BOOST_UNORDERED_EMPLACE_ARGS) : + explicit unique_node(BOOST_UNORDERED_EMPLACE_ARGS) : node_base(), hash_(0) { @@ -49,6 +49,10 @@ namespace boost { namespace unordered { namespace detail { ~unique_node() { boost::unordered::detail::destroy(this->value_ptr()); } + + unique_node(unique_node const&) { + BOOST_ASSERT(false); + } #else unique_node() : node_base(), @@ -59,6 +63,9 @@ namespace boost { namespace unordered { namespace detail { void init(link_pointer) { } + + private: + unique_node& operator=(unique_node const&); }; template @@ -74,7 +81,7 @@ namespace boost { namespace unordered { namespace detail { #if BOOST_UNORDERED_DETAIL_FULL_CONSTRUCT template - ptr_node(BOOST_UNORDERED_EMPLACE_ARGS) : + explicit ptr_node(BOOST_UNORDERED_EMPLACE_ARGS) : bucket_base(), hash_(0) { @@ -85,6 +92,10 @@ namespace boost { namespace unordered { namespace detail { ~ptr_node() { boost::unordered::detail::destroy(this->value_ptr()); } + + ptr_node(ptr_node const&) { + BOOST_ASSERT(false); + } #else ptr_node() : bucket_base(), @@ -95,6 +106,9 @@ namespace boost { namespace unordered { namespace detail { void init(link_pointer) { } + + private: + ptr_node& operator=(ptr_node const&); }; // If the allocator uses raw pointers use ptr_node