From 9f9fdeaa9af07154241df40916604185cc6b20aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= Date: Mon, 29 Aug 2016 16:53:17 +0200 Subject: [PATCH] Adapt to Intrusive change that removed unneeded template parameters to tree_value_compare. --- include/boost/container/detail/tree.hpp | 96 +++++++++++++------------ include/boost/container/map.hpp | 4 +- 2 files changed, 51 insertions(+), 49 deletions(-) diff --git a/include/boost/container/detail/tree.hpp b/include/boost/container/detail/tree.hpp index 399860d..d8b3a6e 100644 --- a/include/boost/container/detail/tree.hpp +++ b/include/boost/container/detail/tree.hpp @@ -394,37 +394,39 @@ class RecyclingCloner intrusive_container &m_icont; }; -template -//where KeyValueCompare is tree_value_compare +template struct key_node_compare - : private KeyValueCompare + : public boost::intrusive::detail::ebo_functor_holder { - BOOST_CONTAINER_FORCEINLINE explicit key_node_compare(const KeyValueCompare &comp) - : KeyValueCompare(comp) + BOOST_CONTAINER_FORCEINLINE explicit key_node_compare(const KeyCompare &comp) + : base_t(comp) {} - template - struct is_node - { - static const bool value = is_same::value; - }; + typedef boost::intrusive::detail::ebo_functor_holder base_t; + typedef KeyCompare key_compare; + typedef KeyOfValue key_of_value; + typedef typename KeyOfValue::type key_type; - template - BOOST_CONTAINER_FORCEINLINE typename enable_if_c::value, const typename KeyValueCompare::value_type &>::type - key_forward(const T &node) const - { return node.get_data(); } + BOOST_CONTAINER_FORCEINLINE const key_compare &key_comp() const + { return static_cast(*this); } - template - #if defined(BOOST_MOVE_HELPERS_RETURN_SFINAE_BROKEN) - BOOST_CONTAINER_FORCEINLINE const T &key_forward(const T &key, typename enable_if_c::value>::type* =0) const - #else - BOOST_CONTAINER_FORCEINLINE typename enable_if_c::value, const T &>::type key_forward(const T &key) const - #endif - { return key; } + BOOST_CONTAINER_FORCEINLINE key_compare &key_comp() + { return static_cast(*this); } - template - BOOST_CONTAINER_FORCEINLINE bool operator()(const KeyType &key1, const KeyType2 &key2) const - { return KeyValueCompare::operator()(this->key_forward(key1), this->key_forward(key2)); } + BOOST_CONTAINER_FORCEINLINE bool operator()(const key_type &key1, const key_type &key2) const + { return this->key_comp()(key1, key2); } + + template + BOOST_CONTAINER_FORCEINLINE bool operator()(const key_type &key1, const U &nonkey2) const + { return this->key_comp()(key1, key_of_value()(nonkey2.get_data())); } + + template + BOOST_CONTAINER_FORCEINLINE bool operator()(const U &nonkey1, const key_type &key2) const + { return this->key_comp()(key_of_value()(nonkey1.get_data()), key2); } + + template + BOOST_CONTAINER_FORCEINLINE bool operator()(const U &nonkey1, const V &nonkey2) const + { return this->key_comp()(key_of_value()(nonkey1.get_data()), key_of_value()(nonkey2.get_data())); } }; template //ValComp + < Allocator, tree_value_compare //ValComp , Options::tree_type, Options::optimize_size>::type > { typedef tree_value_compare - ValComp; + ValComp; typedef typename container_detail::intrusive_tree_type < Allocator, ValComp, Options::tree_type , Options::optimize_size>::type Icont; @@ -497,7 +499,7 @@ class tree private: - typedef key_node_compare KeyNodeCompare; + typedef key_node_compare KeyNodeCompare; public: @@ -815,7 +817,7 @@ class tree (const key_type& key, insert_commit_data &data) { std::pair ret = - this->icont().insert_unique_check(key, KeyNodeCompare(value_comp()), data); + this->icont().insert_unique_check(key, KeyNodeCompare(key_comp()), data); return std::pair(iterator(ret.first), ret.second); } @@ -824,7 +826,7 @@ class tree { BOOST_ASSERT((priv_is_linked)(hint)); std::pair ret = - this->icont().insert_unique_check(hint.get(), key, KeyNodeCompare(value_comp()), data); + this->icont().insert_unique_check(hint.get(), key, KeyNodeCompare(key_comp()), data); return std::pair(iterator(ret.first), ret.second); } @@ -952,8 +954,8 @@ class tree insert_commit_data data; const key_type & k = key; //Support emulated rvalue references std::pair ret = - hint == const_iterator() ? this->icont().insert_unique_check( k, KeyNodeCompare(value_comp()), data) - : this->icont().insert_unique_check(hint.get(), k, KeyNodeCompare(value_comp()), data); + hint == const_iterator() ? this->icont().insert_unique_check( k, KeyNodeCompare(key_comp()), data) + : this->icont().insert_unique_check(hint.get(), k, KeyNodeCompare(key_comp()), data); if(ret.second){ ret.first = this->icont().insert_unique_commit (*AllocHolder::create_node(try_emplace_t(), boost::forward(key), boost::forward(args)...), data); @@ -1000,8 +1002,8 @@ class tree insert_commit_data data;\ const key_type & k = key;\ std::pair ret =\ - hint == const_iterator() ? this->icont().insert_unique_check( k, KeyNodeCompare(value_comp()), data)\ - : this->icont().insert_unique_check(hint.get(), k, KeyNodeCompare(value_comp()), data);\ + hint == const_iterator() ? this->icont().insert_unique_check( k, KeyNodeCompare(key_comp()), data)\ + : this->icont().insert_unique_check(hint.get(), k, KeyNodeCompare(key_comp()), data);\ if(ret.second){\ ret.first = this->icont().insert_unique_commit\ (*AllocHolder::create_node(try_emplace_t(), boost::forward(key) BOOST_MOVE_I##N BOOST_MOVE_FWD##N), data);\ @@ -1080,8 +1082,8 @@ class tree insert_commit_data data; const key_type & k = key; //Support emulated rvalue references std::pair ret = - hint == const_iterator() ? this->icont().insert_unique_check(k, KeyNodeCompare(value_comp()), data) - : this->icont().insert_unique_check(hint.get(), k, KeyNodeCompare(value_comp()), data); + hint == const_iterator() ? this->icont().insert_unique_check(k, KeyNodeCompare(key_comp()), data) + : this->icont().insert_unique_check(hint.get(), k, KeyNodeCompare(key_comp()), data); if(ret.second){ ret.first = this->priv_insert_or_assign_commit(boost::forward(key), boost::forward(obj), data); } @@ -1098,7 +1100,7 @@ class tree } BOOST_CONTAINER_FORCEINLINE size_type erase(const key_type& k) - { return AllocHolder::erase_key(k, KeyNodeCompare(value_comp()), alloc_version()); } + { return AllocHolder::erase_key(k, KeyNodeCompare(key_comp()), alloc_version()); } iterator erase(const_iterator first, const_iterator last) { @@ -1180,37 +1182,37 @@ class tree // search operations. Const and non-const overloads even if no iterator is returned // so splay implementations can to their rebalancing when searching in non-const versions BOOST_CONTAINER_FORCEINLINE iterator find(const key_type& k) - { return iterator(this->icont().find(k, KeyNodeCompare(value_comp()))); } + { return iterator(this->icont().find(k, KeyNodeCompare(key_comp()))); } BOOST_CONTAINER_FORCEINLINE const_iterator find(const key_type& k) const - { return const_iterator(this->non_const_icont().find(k, KeyNodeCompare(value_comp()))); } + { return const_iterator(this->non_const_icont().find(k, KeyNodeCompare(key_comp()))); } BOOST_CONTAINER_FORCEINLINE size_type count(const key_type& k) const - { return size_type(this->icont().count(k, KeyNodeCompare(value_comp()))); } + { return size_type(this->icont().count(k, KeyNodeCompare(key_comp()))); } BOOST_CONTAINER_FORCEINLINE iterator lower_bound(const key_type& k) - { return iterator(this->icont().lower_bound(k, KeyNodeCompare(value_comp()))); } + { return iterator(this->icont().lower_bound(k, KeyNodeCompare(key_comp()))); } BOOST_CONTAINER_FORCEINLINE const_iterator lower_bound(const key_type& k) const - { return const_iterator(this->non_const_icont().lower_bound(k, KeyNodeCompare(value_comp()))); } + { return const_iterator(this->non_const_icont().lower_bound(k, KeyNodeCompare(key_comp()))); } BOOST_CONTAINER_FORCEINLINE iterator upper_bound(const key_type& k) - { return iterator(this->icont().upper_bound(k, KeyNodeCompare(value_comp()))); } + { return iterator(this->icont().upper_bound(k, KeyNodeCompare(key_comp()))); } BOOST_CONTAINER_FORCEINLINE const_iterator upper_bound(const key_type& k) const - { return const_iterator(this->non_const_icont().upper_bound(k, KeyNodeCompare(value_comp()))); } + { return const_iterator(this->non_const_icont().upper_bound(k, KeyNodeCompare(key_comp()))); } std::pair equal_range(const key_type& k) { std::pair ret = - this->icont().equal_range(k, KeyNodeCompare(value_comp())); + this->icont().equal_range(k, KeyNodeCompare(key_comp())); return std::pair(iterator(ret.first), iterator(ret.second)); } std::pair equal_range(const key_type& k) const { std::pair ret = - this->non_const_icont().equal_range(k, KeyNodeCompare(value_comp())); + this->non_const_icont().equal_range(k, KeyNodeCompare(key_comp())); return std::pair (const_iterator(ret.first), const_iterator(ret.second)); } @@ -1218,14 +1220,14 @@ class tree std::pair lower_bound_range(const key_type& k) { std::pair ret = - this->icont().lower_bound_range(k, KeyNodeCompare(value_comp())); + this->icont().lower_bound_range(k, KeyNodeCompare(key_comp())); return std::pair(iterator(ret.first), iterator(ret.second)); } std::pair lower_bound_range(const key_type& k) const { std::pair ret = - this->non_const_icont().lower_bound_range(k, KeyNodeCompare(value_comp())); + this->non_const_icont().lower_bound_range(k, KeyNodeCompare(key_comp())); return std::pair (const_iterator(ret.first), const_iterator(ret.second)); } diff --git a/include/boost/container/map.hpp b/include/boost/container/map.hpp index 219ffe1..76dad08 100644 --- a/include/boost/container/map.hpp +++ b/include/boost/container/map.hpp @@ -120,7 +120,7 @@ class map base_t; typedef container_detail::pair movable_value_type_impl; typedef container_detail::tree_value_compare - < Key, value_type_impl, Compare, select_1st_t> value_compare_impl; + value_compare_impl; #endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED public: @@ -1172,7 +1172,7 @@ class multimap base_t; typedef container_detail::pair movable_value_type_impl; typedef container_detail::tree_value_compare - value_compare_impl; + value_compare_impl; #endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED typedef ::boost::container::allocator_traits allocator_traits_type;