diff options
Diffstat (limited to 'boost/container/detail/tree.hpp')
-rw-r--r-- | boost/container/detail/tree.hpp | 91 |
1 files changed, 27 insertions, 64 deletions
diff --git a/boost/container/detail/tree.hpp b/boost/container/detail/tree.hpp index 0f90b5a4e2..c90202973a 100644 --- a/boost/container/detail/tree.hpp +++ b/boost/container/detail/tree.hpp @@ -43,6 +43,7 @@ #include <boost/intrusive/sgtree.hpp> // intrusive/detail #include <boost/intrusive/detail/minimal_pair_header.hpp> //pair +#include <boost/intrusive/detail/tree_value_compare.hpp> //tree_value_compare // move #include <boost/move/utility_core.hpp> // move/detail @@ -52,57 +53,15 @@ // other #include <boost/core/no_exceptions_support.hpp> -namespace boost { -namespace container { -namespace container_detail { -template<class Key, class T, class Compare, class KeyOfValue> -struct tree_value_compare - : public Compare -{ - typedef T value_type; - typedef Compare key_compare; - typedef KeyOfValue key_of_value; - typedef Key key_type; - explicit tree_value_compare(const key_compare &kcomp) - : Compare(kcomp) - {} - - tree_value_compare() - : Compare() - {} +#include <boost/container/detail/std_fwd.hpp> - const key_compare &key_comp() const - { return static_cast<const key_compare &>(*this); } - - key_compare &key_comp() - { return static_cast<key_compare &>(*this); } - - template<class U> - struct is_key - { - static const bool value = is_same<const U, const key_type>::value; - }; - - template<class U> - typename enable_if_c<is_key<U>::value, const key_type &>::type - key_forward(const U &key) const - { return key; } - - template<class U> - typename enable_if_c<!is_key<U>::value, const key_type &>::type - key_forward(const U &key) const - { return KeyOfValue()(key); } - - template<class KeyType, class KeyType2> - bool operator()(const KeyType &key1, const KeyType2 &key2) const - { return key_compare::operator()(this->key_forward(key1), this->key_forward(key2)); } +namespace boost { +namespace container { +namespace container_detail { - template<class KeyType, class KeyType2> - bool operator()(const KeyType &key1, const KeyType2 &key2) - { return key_compare::operator()(this->key_forward(key1), this->key_forward(key2)); } -}; +using boost::intrusive::tree_value_compare; template<class VoidPointer, boost::container::tree_type_enum tree_type_value, bool OptimizeSize> struct intrusive_tree_hook; @@ -156,7 +115,7 @@ struct tree_internal_data_type template<class T1, class T2> struct tree_internal_data_type< std::pair<T1, T2> > { - typedef pair<T1, T2> type; + typedef pair<typename boost::move_detail::remove_const<T1>::type, T2> type; }; //The node to be store in the tree @@ -549,9 +508,10 @@ class tree tree(bool unique_insertion, InputIterator first, InputIterator last, const key_compare& comp, const allocator_type& a #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED) - , typename container_detail::enable_if_c - < container_detail::is_input_iterator<InputIterator>::value - || container_detail::is_same<alloc_version, version_1>::value + , typename container_detail::enable_if_or + < void + , container_detail::is_same<alloc_version, version_1> + , container_detail::is_input_iterator<InputIterator> >::type * = 0 #endif ) @@ -577,9 +537,10 @@ class tree tree(bool unique_insertion, InputIterator first, InputIterator last, const key_compare& comp, const allocator_type& a #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED) - , typename container_detail::enable_if_c - < !(container_detail::is_input_iterator<InputIterator>::value - || container_detail::is_same<alloc_version, version_1>::value) + , typename container_detail::disable_if_or + < void + , container_detail::is_same<alloc_version, version_1> + , container_detail::is_input_iterator<InputIterator> >::type * = 0 #endif ) @@ -606,10 +567,11 @@ class tree tree( ordered_range_t, InputIterator first, InputIterator last , const key_compare& comp = key_compare(), const allocator_type& a = allocator_type() #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED) - , typename container_detail::enable_if_c - < container_detail::is_input_iterator<InputIterator>::value - || container_detail::is_same<alloc_version, version_1>::value - >::type * = 0 + , typename container_detail::enable_if_or + < void + , container_detail::is_same<alloc_version, version_1> + , container_detail::is_input_iterator<InputIterator> + >::type * = 0 #endif ) : AllocHolder(value_compare(comp), a) @@ -623,10 +585,11 @@ class tree tree( ordered_range_t, InputIterator first, InputIterator last , const key_compare& comp = key_compare(), const allocator_type& a = allocator_type() #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED) - , typename container_detail::enable_if_c - < !(container_detail::is_input_iterator<InputIterator>::value - || container_detail::is_same<alloc_version, version_1>::value) - >::type * = 0 + , typename container_detail::disable_if_or + < void + , container_detail::is_same<alloc_version, version_1> + , container_detail::is_input_iterator<InputIterator> + >::type * = 0 #endif ) : AllocHolder(value_compare(comp), a) @@ -663,7 +626,7 @@ class tree } else{ this->icont().clone_from - (x.icont(), typename AllocHolder::move_cloner(*this), Destroyer(this->node_alloc())); + (boost::move(x.icont()), typename AllocHolder::move_cloner(*this), Destroyer(this->node_alloc())); } } @@ -730,7 +693,7 @@ class tree //Now recreate the source tree reusing nodes stored by other_tree this->icont().clone_from - (x.icont() + (::boost::move(x.icont()) , RecyclingCloner<AllocHolder, true>(*this, other_tree) , Destroyer(this->node_alloc())); |