diff options
Diffstat (limited to 'boost/unordered')
-rw-r--r-- | boost/unordered/detail/buckets.hpp | 30 | ||||
-rw-r--r-- | boost/unordered/detail/table.hpp | 34 |
2 files changed, 33 insertions, 31 deletions
diff --git a/boost/unordered/detail/buckets.hpp b/boost/unordered/detail/buckets.hpp index 7de4317b5a..8a67345c95 100644 --- a/boost/unordered/detail/buckets.hpp +++ b/boost/unordered/detail/buckets.hpp @@ -45,9 +45,9 @@ namespace boost { namespace unordered { namespace iterator_detail { // all no throw template <typename Node> struct iterator; - template <typename Node, typename ConstNodePointer> struct c_iterator; + template <typename Node> struct c_iterator; template <typename Node, typename Policy> struct l_iterator; - template <typename Node, typename ConstNodePointer, typename Policy> + template <typename Node, typename Policy> struct cl_iterator; // Local Iterators @@ -64,12 +64,12 @@ namespace boost { namespace unordered { namespace iterator_detail { typename Node::value_type&> { #if !defined(BOOST_NO_MEMBER_TEMPLATE_FRIENDS) - template <typename Node2, typename ConstNodePointer, typename Policy2> + template <typename Node2, typename Policy2> friend struct boost::unordered::iterator_detail::cl_iterator; private: #endif typedef typename Node::node_pointer node_pointer; - typedef boost::unordered::iterator_detail::iterator<Node> iterator; + typedef boost::unordered::iterator_detail::iterator<Node> n_iterator; node_pointer ptr_; std::size_t bucket_; std::size_t bucket_count_; @@ -80,7 +80,7 @@ namespace boost { namespace unordered { namespace iterator_detail { l_iterator() BOOST_NOEXCEPT : ptr_() {} - l_iterator(iterator x, std::size_t b, std::size_t c) BOOST_NOEXCEPT + l_iterator(n_iterator x, std::size_t b, std::size_t c) BOOST_NOEXCEPT : ptr_(x.node_), bucket_(b), bucket_count_(c) {} value_type& operator*() const { @@ -114,7 +114,7 @@ namespace boost { namespace unordered { namespace iterator_detail { } }; - template <typename Node, typename ConstNodePointer, typename Policy> + template <typename Node, typename Policy> struct cl_iterator : public boost::iterator< std::forward_iterator_tag, @@ -128,7 +128,7 @@ namespace boost { namespace unordered { namespace iterator_detail { private: typedef typename Node::node_pointer node_pointer; - typedef boost::unordered::iterator_detail::iterator<Node> iterator; + typedef boost::unordered::iterator_detail::iterator<Node> n_iterator; node_pointer ptr_; std::size_t bucket_; std::size_t bucket_count_; @@ -139,7 +139,7 @@ namespace boost { namespace unordered { namespace iterator_detail { cl_iterator() BOOST_NOEXCEPT : ptr_() {} - cl_iterator(iterator x, std::size_t b, std::size_t c) BOOST_NOEXCEPT : + cl_iterator(n_iterator x, std::size_t b, std::size_t c) BOOST_NOEXCEPT : ptr_(x.node_), bucket_(b), bucket_count_(c) {} cl_iterator(boost::unordered::iterator_detail::l_iterator< @@ -192,11 +192,11 @@ namespace boost { namespace unordered { namespace iterator_detail { typename Node::value_type&> { #if !defined(BOOST_NO_MEMBER_TEMPLATE_FRIENDS) - template <typename, typename> + template <typename> friend struct boost::unordered::iterator_detail::c_iterator; template <typename, typename> friend struct boost::unordered::iterator_detail::l_iterator; - template <typename, typename, typename> + template <typename, typename> friend struct boost::unordered::iterator_detail::cl_iterator; template <typename> friend struct boost::unordered::detail::table; @@ -223,7 +223,7 @@ namespace boost { namespace unordered { namespace iterator_detail { } value_type* operator->() const { - return &node_->value(); + return node_->value_ptr(); } iterator& operator++() { @@ -246,7 +246,7 @@ namespace boost { namespace unordered { namespace iterator_detail { } }; - template <typename Node, typename ConstNodePointer> + template <typename Node> struct c_iterator : public boost::iterator< std::forward_iterator_tag, @@ -268,7 +268,7 @@ namespace boost { namespace unordered { namespace iterator_detail { private: #endif typedef typename Node::node_pointer node_pointer; - typedef boost::unordered::iterator_detail::iterator<Node> iterator; + typedef boost::unordered::iterator_detail::iterator<Node> n_iterator; node_pointer node_; public: @@ -280,14 +280,14 @@ namespace boost { namespace unordered { namespace iterator_detail { explicit c_iterator(typename Node::link_pointer x) BOOST_NOEXCEPT : node_(static_cast<node_pointer>(x)) {} - c_iterator(iterator const& x) BOOST_NOEXCEPT : node_(x.node_) {} + c_iterator(n_iterator const& x) BOOST_NOEXCEPT : node_(x.node_) {} value_type const& operator*() const { return node_->value(); } value_type const* operator->() const { - return &node_->value(); + return node_->value_ptr(); } c_iterator& operator++() { diff --git a/boost/unordered/detail/table.hpp b/boost/unordered/detail/table.hpp index 2bb5d45003..b356ca2203 100644 --- a/boost/unordered/detail/table.hpp +++ b/boost/unordered/detail/table.hpp @@ -191,11 +191,11 @@ namespace boost { namespace unordered { namespace detail { typedef boost::unordered::iterator_detail:: iterator<node> iterator; typedef boost::unordered::iterator_detail:: - c_iterator<node, const_node_pointer> c_iterator; + c_iterator<node> c_iterator; typedef boost::unordered::iterator_detail:: l_iterator<node, policy> l_iterator; typedef boost::unordered::iterator_detail:: - cl_iterator<node, const_node_pointer, policy> cl_iterator; + cl_iterator<node, policy> cl_iterator; //////////////////////////////////////////////////////////////////////// // Members @@ -343,7 +343,7 @@ namespace boost { namespace unordered { namespace detail { return policy::new_bucket_count( boost::unordered::detail::double_to_size(floor( static_cast<double>(size) / - static_cast<double>(mlf_))) + 1); + static_cast<double>(mlf_)) + 1)); } //////////////////////////////////////////////////////////////////////// @@ -500,9 +500,11 @@ namespace boost { namespace unordered { namespace detail { op2.commit(); } + // Only call with nodes allocated with the currect allocator, or + // one that is equal to it. (Can't assert because other's + // allocators might have already been moved). void move_buckets_from(table& other) { - BOOST_ASSERT(node_alloc() == other.node_alloc()); BOOST_ASSERT(!buckets_); buckets_ = other.buckets_; bucket_count_ = other.bucket_count_; @@ -710,15 +712,25 @@ namespace boost { namespace unordered { namespace detail { void move_assign(table& x, true_type) { delete_buckets(); + set_hash_functions new_func_this(*this, x); allocators_.move_assign(x.allocators_); - move_assign_no_alloc(x); + // No throw from here. + mlf_ = x.mlf_; + max_load_ = x.max_load_; + move_buckets_from(x); + new_func_this.commit(); } void move_assign(table& x, false_type) { if (node_alloc() == x.node_alloc()) { delete_buckets(); - move_assign_no_alloc(x); + set_hash_functions new_func_this(*this, x); + // No throw from here. + mlf_ = x.mlf_; + max_load_ = x.max_load_; + move_buckets_from(x); + new_func_this.commit(); } else { set_hash_functions new_func_this(*this, x); @@ -743,16 +755,6 @@ namespace boost { namespace unordered { namespace detail { table_impl::fill_buckets(nodes.begin(), *this, node_creator); } } - - void move_assign_no_alloc(table& x) - { - set_hash_functions new_func_this(*this, x); - // No throw from here. - mlf_ = x.mlf_; - max_load_ = x.max_load_; - move_buckets_from(x); - new_func_this.commit(); - } // Accessors |