diff options
author | DongHun Kwak <dh0128.kwak@samsung.com> | 2016-10-06 10:33:54 +0900 |
---|---|---|
committer | DongHun Kwak <dh0128.kwak@samsung.com> | 2016-10-06 10:36:09 +0900 |
commit | d9ec475d945d3035377a0d89ed42e382d8988891 (patch) | |
tree | 34aff2cee4b209906243ab5499d61f3edee2982f /boost/intrusive | |
parent | 71d216b90256936a9638f325af9bc69d720e75de (diff) | |
download | boost-d9ec475d945d3035377a0d89ed42e382d8988891.tar.gz boost-d9ec475d945d3035377a0d89ed42e382d8988891.tar.bz2 boost-d9ec475d945d3035377a0d89ed42e382d8988891.zip |
Imported Upstream version 1.60.0
Change-Id: Ie709530d6d5841088ceaba025cbe175a4ef43050
Signed-off-by: DongHun Kwak <dh0128.kwak@samsung.com>
Diffstat (limited to 'boost/intrusive')
-rw-r--r-- | boost/intrusive/avl_set.hpp | 4 | ||||
-rw-r--r-- | boost/intrusive/bs_set.hpp | 4 | ||||
-rw-r--r-- | boost/intrusive/bstree.hpp | 172 | ||||
-rw-r--r-- | boost/intrusive/detail/ebo_functor_holder.hpp | 132 | ||||
-rw-r--r-- | boost/intrusive/detail/has_member_function_callable_with.hpp | 13 | ||||
-rw-r--r-- | boost/intrusive/detail/key_nodeptr_comp.hpp | 10 | ||||
-rw-r--r-- | boost/intrusive/detail/math.hpp | 22 | ||||
-rw-r--r-- | boost/intrusive/detail/parent_from_member.hpp | 4 | ||||
-rw-r--r-- | boost/intrusive/detail/std_fwd.hpp | 30 | ||||
-rw-r--r-- | boost/intrusive/detail/tree_iterator.hpp | 21 | ||||
-rw-r--r-- | boost/intrusive/detail/tree_value_compare.hpp | 23 | ||||
-rw-r--r-- | boost/intrusive/intrusive_fwd.hpp | 14 | ||||
-rw-r--r-- | boost/intrusive/pointer_plus_bits.hpp | 14 | ||||
-rw-r--r-- | boost/intrusive/pointer_traits.hpp | 14 | ||||
-rw-r--r-- | boost/intrusive/rbtree_algorithms.hpp | 4 | ||||
-rw-r--r-- | boost/intrusive/set.hpp | 4 | ||||
-rw-r--r-- | boost/intrusive/sg_set.hpp | 4 | ||||
-rw-r--r-- | boost/intrusive/sgtree.hpp | 17 | ||||
-rw-r--r-- | boost/intrusive/splay_set.hpp | 4 | ||||
-rw-r--r-- | boost/intrusive/treap_set.hpp | 4 |
20 files changed, 291 insertions, 223 deletions
diff --git a/boost/intrusive/avl_set.hpp b/boost/intrusive/avl_set.hpp index c3d8d999ac..5c51e5978d 100644 --- a/boost/intrusive/avl_set.hpp +++ b/boost/intrusive/avl_set.hpp @@ -328,7 +328,7 @@ class avl_set_impl //! @copydoc ::boost::intrusive::rbtree::equal_range(const KeyType&,KeyTypeKeyCompare) template<class KeyType, class KeyTypeKeyCompare> std::pair<iterator,iterator> equal_range(const KeyType& key, KeyTypeKeyCompare comp) - { return this->tree_type::lower_bound_range(key, comp); } + { return this->tree_type::equal_range(key, comp); } //! @copydoc ::boost::intrusive::rbtree::equal_range(const key_type &)const std::pair<const_iterator, const_iterator> @@ -339,7 +339,7 @@ class avl_set_impl template<class KeyType, class KeyTypeKeyCompare> std::pair<const_iterator, const_iterator> equal_range(const KeyType& key, KeyTypeKeyCompare comp) const - { return this->tree_type::lower_bound_range(key, comp); } + { return this->tree_type::equal_range(key, comp); } #ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED diff --git a/boost/intrusive/bs_set.hpp b/boost/intrusive/bs_set.hpp index a46ca38a01..2f560f5863 100644 --- a/boost/intrusive/bs_set.hpp +++ b/boost/intrusive/bs_set.hpp @@ -325,7 +325,7 @@ class bs_set_impl //! @copydoc ::boost::intrusive::bstree::equal_range(const KeyType&,KeyTypeKeyCompare) template<class KeyType, class KeyTypeKeyCompare> std::pair<iterator,iterator> equal_range(const KeyType& key, KeyTypeKeyCompare comp) - { return this->tree_type::lower_bound_range(key, comp); } + { return this->tree_type::equal_range(key, comp); } //! @copydoc ::boost::intrusive::bstree::equal_range(const key_type &)const std::pair<const_iterator, const_iterator> @@ -336,7 +336,7 @@ class bs_set_impl template<class KeyType, class KeyTypeKeyCompare> std::pair<const_iterator, const_iterator> equal_range(const KeyType& key, KeyTypeKeyCompare comp) const - { return this->tree_type::lower_bound_range(key, comp); } + { return this->tree_type::equal_range(key, comp); } #ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED diff --git a/boost/intrusive/bstree.hpp b/boost/intrusive/bstree.hpp index 7a67de6e12..b08c49b5f1 100644 --- a/boost/intrusive/bstree.hpp +++ b/boost/intrusive/bstree.hpp @@ -360,7 +360,11 @@ struct bstbase2 } template<class KeyTypeKeyCompare> - detail::key_nodeptr_comp<KeyTypeKeyCompare, value_traits, key_of_value> key_node_comp(KeyTypeKeyCompare comp) const + struct key_node_comp_ret + { typedef detail::key_nodeptr_comp<KeyTypeKeyCompare, value_traits, key_of_value> type; }; + + template<class KeyTypeKeyCompare> + typename key_node_comp_ret<KeyTypeKeyCompare>::type key_node_comp(KeyTypeKeyCompare comp) const { return detail::key_nodeptr_comp<KeyTypeKeyCompare, value_traits, key_of_value>(comp, &this->get_value_traits()); } @@ -1245,6 +1249,19 @@ class bstree_impl node_ptr to_insert(this->get_value_traits().to_node_ptr(value)); if(safemode_or_autounlink) BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(node_algorithms::unique(to_insert)); + + #if !(defined(BOOST_DISABLE_ASSERTS) || ( defined(BOOST_ENABLE_ASSERT_DEBUG_HANDLER) && defined(NDEBUG) )) + //Test insertion position is correct + iterator p(commit_data.node, this->priv_value_traits_ptr()); + if(!commit_data.link_left){ + ++p; + } + //Check if the insertion point is correct to detect wrong + //uses insert_unique_check + BOOST_ASSERT(( p == this->end() || !this->comp()(*p, value) )); + BOOST_ASSERT(( p == this->begin() || !this->comp()(value, *--p) )); + #endif + node_algorithms::insert_unique_commit (this->header_ptr(), to_insert, commit_data); this->sz_traits().increment(); @@ -1368,6 +1385,10 @@ class bstree_impl size_type erase(const key_type &key) { return this->erase(key, this->key_comp()); } + //! <b>Requires</b>: key is a value such that `*this` is partitioned with respect to + //! comp(nk, key) and !comp(key, nk), with comp(nk, key) implying !comp(key, nk), + //! with nk the key_type of a value_type inserted into `*this`. + //! //! <b>Effects</b>: Erases all the elements with the given key. //! according to the comparison functor "comp". //! @@ -1448,6 +1469,10 @@ class bstree_impl iterator erase_and_dispose(const_iterator b, const_iterator e, Disposer disposer) { size_type n; return this->private_erase(b, e, n, disposer); } + //! <b>Requires</b>: key is a value such that `*this` is partitioned with respect to + //! comp(nk, key) and !comp(key, nk), with comp(nk, key) implying !comp(key, nk) + //! and nk the key_type of a value_type inserted into `*this`. + //! //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw. //! //! <b>Effects</b>: Erases all the elements with the given key. @@ -1520,6 +1545,10 @@ class bstree_impl size_type count(const key_type &key) const { return size_type(this->count(key, this->key_comp())); } + //! <b>Requires</b>: key is a value such that `*this` is partitioned with respect to + //! comp(nk, key) and !comp(key, nk), with comp(nk, key) implying !comp(key, nk), + //! and nk the key_type of a value_type inserted into `*this`. + //! //! <b>Effects</b>: Returns the number of contained elements with the given key //! //! <b>Complexity</b>: Logarithmic to the number of elements contained plus lineal @@ -1569,21 +1598,11 @@ class bstree_impl //! <b>Throws</b>: If `key_compare` throws. const_iterator lower_bound(const key_type &key) const; - //! <b>Effects</b>: Returns an iterator to the first element whose - //! key is not less than k or end() if that element does not exist. - //! - //! <b>Complexity</b>: Logarithmic. - //! - //! <b>Throws</b>: If `comp` throws. + //! @copydoc ::boost::intrusive::bstree::lower_bound(const key_type &) template<class KeyType, class KeyTypeKeyCompare> iterator lower_bound(const KeyType &key, KeyTypeKeyCompare comp); - //! <b>Effects</b>: Returns a const iterator to the first element whose - //! key is not less than k or end() if that element does not exist. - //! - //! <b>Complexity</b>: Logarithmic. - //! - //! <b>Throws</b>: If `comp` throws. + //! @copydoc ::boost::intrusive::bstree::lower_bound(const KeyType&,KeyTypeKeyCompare) template<class KeyType, class KeyTypeKeyCompare> const_iterator lower_bound(const KeyType &key, KeyTypeKeyCompare comp) const; @@ -1595,6 +1614,9 @@ class bstree_impl //! <b>Throws</b>: If `key_compare` throws. iterator upper_bound(const key_type &key); + //! <b>Requires</b>: key is a value such that `*this` is partitioned with respect to + //! !comp(key, nk), with nk the key_type of a value_type inserted into `*this`. + //! //! <b>Effects</b>: Returns an iterator to the first element whose //! key is greater than k according to comp or end() if that element //! does not exist. @@ -1605,21 +1627,10 @@ class bstree_impl template<class KeyType, class KeyTypeKeyCompare> iterator upper_bound(const KeyType &key, KeyTypeKeyCompare comp); - //! <b>Effects</b>: Returns an iterator to the first element whose - //! key is greater than k or end() if that element does not exist. - //! - //! <b>Complexity</b>: Logarithmic. - //! - //! <b>Throws</b>: If `key_compare` throws. + //! @copydoc ::boost::intrusive::bstree::upper_bound(const key_type &) const_iterator upper_bound(const key_type &key) const; - //! <b>Effects</b>: Returns an iterator to the first element whose - //! key is greater than k according to comp or end() if that element - //! does not exist. - //! - //! <b>Complexity</b>: Logarithmic. - //! - //! <b>Throws</b>: If `comp` throws. + //! @copydoc ::boost::intrusive::bstree::upper_bound(const KeyType&,KeyTypeKeyCompare) template<class KeyType, class KeyTypeKeyCompare> const_iterator upper_bound(const KeyType &key, KeyTypeKeyCompare comp) const; @@ -1631,6 +1642,10 @@ class bstree_impl //! <b>Throws</b>: If `key_compare` throws. iterator find(const key_type &key); + //! <b>Requires</b>: key is a value such that `*this` is partitioned with respect to + //! comp(nk, key) and !comp(key, nk), with comp(nk, key) implying !comp(key, nk), + //! and nk the key_type of a value_type inserted into `*this`. + //! //! <b>Effects</b>: Finds an iterator to the first element whose key is //! k or end() if that element does not exist. //! @@ -1640,20 +1655,10 @@ class bstree_impl template<class KeyType, class KeyTypeKeyCompare> iterator find(const KeyType &key, KeyTypeKeyCompare comp); - //! <b>Effects</b>: Finds a const_iterator to the first element whose key is - //! k or end() if that element does not exist. - //! - //! <b>Complexity</b>: Logarithmic. - //! - //! <b>Throws</b>: If `key_compare` throws. + //! @copydoc ::boost::intrusive::bstree::find(const key_type &) const_iterator find(const key_type &key) const; - //! <b>Effects</b>: Finds a const_iterator to the first element whose key is - //! k or end() if that element does not exist. - //! - //! <b>Complexity</b>: Logarithmic. - //! - //! <b>Throws</b>: If `comp` throws. + //! @copydoc ::boost::intrusive::bstree::find(const KeyType&,KeyTypeKeyCompare) template<class KeyType, class KeyTypeKeyCompare> const_iterator find(const KeyType &key, KeyTypeKeyCompare comp) const; @@ -1666,6 +1671,10 @@ class bstree_impl //! <b>Throws</b>: If `key_compare` throws. std::pair<iterator,iterator> equal_range(const key_type &key); + //! <b>Requires</b>: key is a value such that `*this` is partitioned with respect to + //! comp(nk, key) and !comp(key, nk), with comp(nk, key) implying !comp(key, nk), + //! with nk the key_type of a value_type inserted into `*this`. + //! //! <b>Effects</b>: Finds a range containing all elements whose key is k or //! an empty range that indicates the position where those elements would be //! if they there is no elements with key k. @@ -1676,29 +1685,21 @@ class bstree_impl template<class KeyType, class KeyTypeKeyCompare> std::pair<iterator,iterator> equal_range(const KeyType &key, KeyTypeKeyCompare comp); - //! <b>Effects</b>: Finds a range containing all elements whose key is k or - //! an empty range that indicates the position where those elements would be - //! if they there is no elements with key k. - //! - //! <b>Complexity</b>: Logarithmic. - //! - //! <b>Throws</b>: If `key_compare` throws. - std::pair<const_iterator, const_iterator> - equal_range(const key_type &key) const; + //! @copydoc ::boost::intrusive::bstree::equal_range(const key_type &) + std::pair<const_iterator, const_iterator> equal_range(const key_type &key) const; - //! <b>Effects</b>: Finds a range containing all elements whose key is k or - //! an empty range that indicates the position where those elements would be - //! if they there is no elements with key k. - //! - //! <b>Complexity</b>: Logarithmic. - //! - //! <b>Throws</b>: If `comp` throws. + //! @copydoc ::boost::intrusive::bstree::equal_range(const KeyType&,KeyTypeKeyCompare) template<class KeyType, class KeyTypeKeyCompare> std::pair<const_iterator, const_iterator> equal_range(const KeyType &key, KeyTypeKeyCompare comp) const; - //! <b>Requires</b>: 'lower_key' must not be greater than 'upper_key'. If - //! 'lower_key' == 'upper_key', ('left_closed' || 'right_closed') must be false. + //! <b>Requires</b>: + //! `upper_key` shall not precede `lower_key` according to key_compare. + //! [key_comp()(upper_key, lower_key) shall be false] + //! + //! If `lower_key` is equivalent to `upper_key` + //! [!key_comp()(upper_key, lower_key) && !key_comp()(lower_key, upper_key)] then + //! ('left_closed' || 'right_closed') must be false. //! //! <b>Effects</b>: Returns an a pair with the following criteria: //! @@ -1717,11 +1718,19 @@ class bstree_impl std::pair<iterator,iterator> bounded_range (const key_type &lower_key, const key_type &upper_value, bool left_closed, bool right_closed); - //! <b>Requires</b>: KeyTypeKeyCompare is a function object that induces a strict weak - //! ordering compatible with the strict weak ordering used to create the - //! the container. - //! 'lower_key' must not be greater than 'upper_key' according to 'comp'. If - //! 'lower_key' == 'upper_key', ('left_closed' || 'right_closed') must be false. + //! <b>Requires</b>: + //! `lower_key` is a value such that `*this` is partitioned with respect to + //! comp(nk, lower_key) if left_closed is true, with respect to !comp(lower_key, nk) otherwise. + //! + //! `upper_key` is a value such that `*this` is partitioned with respect to + //! !comp(upper_key, nk) if right_closed is true, with respect to comp(nk, upper_key) otherwise. + //! + //! `upper_key` shall not precede `lower_key` according to comp + //! [comp(upper_key, lower_key) shall be false] + //! + //! If `lower_key` is equivalent to `upper_key` + //! [!comp(upper_key, lower_key) && !comp(lower_key, upper_key)] then + //! ('left_closed' || 'right_closed') must be false. //! //! <b>Effects</b>: Returns an a pair with the following criteria: //! @@ -1740,47 +1749,12 @@ class bstree_impl template<class KeyType, class KeyTypeKeyCompare> std::pair<iterator,iterator> bounded_range (const KeyType &lower_key, const KeyType &upper_key, KeyTypeKeyCompare comp, bool left_closed, bool right_closed); - - //! <b>Requires</b>: 'lower_key' must not be greater than 'upper_key'. If - //! 'lower_key' == 'upper_key', ('left_closed' || 'right_closed') must be false. - //! - //! <b>Effects</b>: Returns an a pair with the following criteria: - //! - //! first = lower_bound(lower_key) if left_closed, upper_bound(lower_key) otherwise - //! - //! second = upper_bound(upper_key) if right_closed, lower_bound(upper_key) otherwise - //! - //! <b>Complexity</b>: Logarithmic. - //! - //! <b>Throws</b>: If `key_compare` throws. - //! - //! <b>Note</b>: This function can be more efficient than calling upper_bound - //! and lower_bound for lower_value and upper_value. - //! - //! <b>Note</b>: Experimental function, the interface might change in future releases. + + //! @copydoc ::boost::intrusive::bstree::bounded_range(const key_type &,const key_type &,bool,bool) std::pair<const_iterator,const_iterator> bounded_range (const key_type &lower_key, const key_type &upper_key, bool left_closed, bool right_closed) const; - //! <b>Requires</b>: KeyTypeKeyCompare is a function object that induces a strict weak - //! ordering compatible with the strict weak ordering used to create the - //! the container. - //! 'lower_key' must not be greater than 'upper_key' according to 'comp'. If - //! 'lower_key' == 'upper_key', ('left_closed' || 'right_closed') must be false. - //! - //! <b>Effects</b>: Returns an a pair with the following criteria: - //! - //! first = lower_bound(lower_key, comp) if left_closed, upper_bound(lower_key, comp) otherwise - //! - //! second = upper_bound(upper_key, comp) if right_closed, lower_bound(upper_key, comp) otherwise - //! - //! <b>Complexity</b>: Logarithmic. - //! - //! <b>Throws</b>: If `comp` throws. - //! - //! <b>Note</b>: This function can be more efficient than calling upper_bound - //! and lower_bound for lower_key and upper_key. - //! - //! <b>Note</b>: Experimental function, the interface might change in future releases. + //! @copydoc ::boost::intrusive::bstree::bounded_range(const KeyType&,const KeyType&,KeyTypeKeyCompare,bool,bool) template<class KeyType, class KeyTypeKeyCompare> std::pair<const_iterator,const_iterator> bounded_range (const KeyType &lower_key, const KeyType &upper_key, KeyTypeKeyCompare comp, bool left_closed, bool right_closed) const; diff --git a/boost/intrusive/detail/ebo_functor_holder.hpp b/boost/intrusive/detail/ebo_functor_holder.hpp index 27dd093b60..9fec5a32b7 100644 --- a/boost/intrusive/detail/ebo_functor_holder.hpp +++ b/boost/intrusive/detail/ebo_functor_holder.hpp @@ -22,6 +22,8 @@ # pragma once #endif +#include <boost/move/utility_core.hpp> + namespace boost { namespace intrusive { namespace detail { @@ -155,20 +157,63 @@ template<typename T> struct is_unary_or_binary_function : is_unary_or_binary_function_impl<T> {}; -template<typename T, bool IsEmpty = true> -class ebo_functor_holder_impl +template<typename T, bool = is_unary_or_binary_function<T>::value> +class ebo_functor_holder { + BOOST_COPYABLE_AND_MOVABLE(ebo_functor_holder) + public: - ebo_functor_holder_impl() + typedef T functor_type; + + ebo_functor_holder() + : t_() + {} + + explicit ebo_functor_holder(const T &t) + : t_(t) {} - ebo_functor_holder_impl(const T& t) - : t_(t) + + explicit ebo_functor_holder(BOOST_RV_REF(T) t) + : t_(::boost::move(t)) {} + template<class Arg1, class Arg2> - ebo_functor_holder_impl(const Arg1& arg1, const Arg2& arg2) - : t_(arg1, arg2) + ebo_functor_holder(BOOST_FWD_REF(Arg1) arg1, BOOST_FWD_REF(Arg2) arg2) + : t_(::boost::forward<Arg1>(arg1), ::boost::forward<Arg2>(arg2)) + {} + + ebo_functor_holder(const ebo_functor_holder &x) + : t_(x) + {} + + ebo_functor_holder(BOOST_RV_REF(ebo_functor_holder) x) + : t_(x.t_) {} + ebo_functor_holder& operator=(BOOST_COPY_ASSIGN_REF(ebo_functor_holder) x) + { + this->get() = x.get(); + return *this; + } + + ebo_functor_holder& operator=(BOOST_RV_REF(ebo_functor_holder) x) + { + this->get() = ::boost::move(x.get()); + return *this; + } + + ebo_functor_holder& operator=(const T &x) + { + this->get() = x; + return *this; + } + + ebo_functor_holder& operator=(BOOST_RV_REF(T) x) + { + this->get() = ::boost::move(x); + return *this; + } + T& get(){return t_;} const T& get()const{return t_;} @@ -177,50 +222,67 @@ class ebo_functor_holder_impl }; template<typename T> -class ebo_functor_holder_impl<T, false> +class ebo_functor_holder<T, false> : public T { + BOOST_COPYABLE_AND_MOVABLE(ebo_functor_holder) + public: - ebo_functor_holder_impl() - {} - explicit ebo_functor_holder_impl(const T& t) - : T(t) + typedef T functor_type; + + ebo_functor_holder() + : T() {} - template<class Arg1, class Arg2> - ebo_functor_holder_impl(const Arg1& arg1, const Arg2& arg2) - : T(arg1, arg2) + + explicit ebo_functor_holder(const T &t) + : T(t) {} - T& get(){return *this;} - const T& get()const{return *this;} -}; + explicit ebo_functor_holder(BOOST_RV_REF(T) t) + : T(::boost::move(t)) + {} -template<typename T> -class ebo_functor_holder - : public ebo_functor_holder_impl<T, is_unary_or_binary_function<T>::value> -{ - private: - typedef ebo_functor_holder_impl<T, is_unary_or_binary_function<T>::value> super; + template<class Arg1, class Arg2> + ebo_functor_holder(BOOST_FWD_REF(Arg1) arg1, BOOST_FWD_REF(Arg2) arg2) + : T(::boost::forward<Arg1>(arg1), ::boost::forward<Arg2>(arg2)) + {} - public: - typedef T functor_type; - ebo_functor_holder(){} - explicit ebo_functor_holder(const T& t) - : super(t) + ebo_functor_holder(const ebo_functor_holder &x) + : T(static_cast<const T&>(x)) {} - template<class Arg1, class Arg2> - ebo_functor_holder(const Arg1& arg1, const Arg2& arg2) - : super(arg1, arg2) + ebo_functor_holder(BOOST_RV_REF(ebo_functor_holder) x) + : T(BOOST_MOVE_BASE(T, x)) {} - ebo_functor_holder& operator=(const ebo_functor_holder& x) + ebo_functor_holder& operator=(BOOST_COPY_ASSIGN_REF(ebo_functor_holder) x) { - this->get()=x.get(); + const ebo_functor_holder&r = x; + this->get() = x.get(); + return *this; + } + + ebo_functor_holder& operator=(BOOST_RV_REF(ebo_functor_holder) x) + { + this->get() = ::boost::move(x.get()); + return *this; + } + + ebo_functor_holder& operator=(const T &x) + { + this->get() = x; + return *this; + } + + ebo_functor_holder& operator=(BOOST_RV_REF(T) x) + { + this->get() = ::boost::move(x); return *this; } -}; + T& get(){return *this;} + const T& get()const{return *this;} +}; } //namespace detail { } //namespace intrusive { diff --git a/boost/intrusive/detail/has_member_function_callable_with.hpp b/boost/intrusive/detail/has_member_function_callable_with.hpp index 30bef56c2b..c9a8e7e637 100644 --- a/boost/intrusive/detail/has_member_function_callable_with.hpp +++ b/boost/intrusive/detail/has_member_function_callable_with.hpp @@ -167,7 +167,11 @@ BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_BEG void BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME(); }; - struct Base : public boost_intrusive_hmfcw::remove_cv<Type>::type, public BaseMixin {}; + struct Base + : public boost_intrusive_hmfcw::remove_cv<Type>::type, public BaseMixin + { //Declare the unneeded default constructor as some old compilers wrongly require it with is_convertible + Base(); + }; template <typename T, T t> class Helper{}; template <typename U> @@ -244,11 +248,16 @@ BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_BEG #if BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_MAX > 0 //1 to N arg specialization when BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME is present + //Declare some unneeded default constructor as some old compilers wrongly require it with is_convertible #if defined(BOOST_NO_CXX11_DECLTYPE) #define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_ITERATION(N)\ - template<class Fun> struct BOOST_MOVE_CAT(FunWrap##N, BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME) : Fun\ + \ + template<class Fun>\ + struct BOOST_MOVE_CAT(FunWrap##N, BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME)\ + : Fun\ {\ using Fun::BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME;\ + BOOST_MOVE_CAT(FunWrap##N, BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME)();\ boost_intrusive_hmfcw::private_type BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME\ (BOOST_MOVE_REPEAT##N(boost_intrusive_hmfcw::dont_care)) const;\ };\ diff --git a/boost/intrusive/detail/key_nodeptr_comp.hpp b/boost/intrusive/detail/key_nodeptr_comp.hpp index df2b895db9..1a5ec32acc 100644 --- a/boost/intrusive/detail/key_nodeptr_comp.hpp +++ b/boost/intrusive/detail/key_nodeptr_comp.hpp @@ -60,13 +60,15 @@ struct key_nodeptr_comp //key_forward template<class T> - typename enable_if<is_node_ptr<T>, const key_type &>::type - key_forward(const T &node) const + typename enable_if<is_node_ptr<T>, const key_type &>::type key_forward(const T &node) const { return key_of_value()(*traits_->to_value_ptr(node)); } template<class T> - typename disable_if<is_node_ptr<T>, const T &>::type - const key_forward(const T &key) const + #if defined(BOOST_MOVE_HELPERS_RETURN_SFINAE_BROKEN) + const T &key_forward (const T &key, typename disable_if<is_node_ptr<T> >::type* =0) const + #else + typename disable_if<is_node_ptr<T>, const T &>::type key_forward(const T &key) const + #endif { return key; } //operator() 1 arg diff --git a/boost/intrusive/detail/math.hpp b/boost/intrusive/detail/math.hpp index dfebe2ab42..4901053cb3 100644 --- a/boost/intrusive/detail/math.hpp +++ b/boost/intrusive/detail/math.hpp @@ -23,6 +23,7 @@ #include <cstddef> #include <climits> +#include <boost/intrusive/detail/mpl.hpp> namespace boost { namespace intrusive { @@ -227,9 +228,28 @@ inline float fast_log2 (float val) return val + static_cast<float>(log_2); } +inline bool is_pow2(std::size_t x) +{ return (x & (x-1)) == 0; } + +template<std::size_t N> +struct static_is_pow2 +{ + static const bool value = (N & (N-1)) == 0; +}; + inline std::size_t ceil_log2 (std::size_t x) { - return static_cast<std::size_t>((x & (x-1)) != 0) + floor_log2(x); + return static_cast<std::size_t>(!(is_pow2)(x)) + floor_log2(x); +} + +inline std::size_t ceil_pow2 (std::size_t x) +{ + return std::size_t(1u) << (ceil_log2)(x); +} + +inline std::size_t previous_or_equal_pow2(std::size_t x) +{ + return std::size_t(1u) << floor_log2(x); } template<class SizeType, std::size_t N> diff --git a/boost/intrusive/detail/parent_from_member.hpp b/boost/intrusive/detail/parent_from_member.hpp index 30eba13e16..8701c3f269 100644 --- a/boost/intrusive/detail/parent_from_member.hpp +++ b/boost/intrusive/detail/parent_from_member.hpp @@ -115,10 +115,6 @@ inline const Parent *parent_from_member(const Member *member, const Member Paren } //namespace intrusive { } //namespace boost { -#ifdef BOOST_INTRUSIVE_MSVC_ABI_PTR_TO_MEMBER -#undef BOOST_INTRUSIVE_MSVC_ABI_PTR_TO_MEMBER -#endif - #include <boost/intrusive/detail/config_end.hpp> #endif //#ifndef BOOST_INTRUSIVE_DETAIL_PARENT_FROM_MEMBER_HPP diff --git a/boost/intrusive/detail/std_fwd.hpp b/boost/intrusive/detail/std_fwd.hpp index 4b5cedbae3..8193ea8ed1 100644 --- a/boost/intrusive/detail/std_fwd.hpp +++ b/boost/intrusive/detail/std_fwd.hpp @@ -23,26 +23,8 @@ // Standard predeclarations ////////////////////////////////////////////////////////////////////////////// -#if defined(_LIBCPP_VERSION) - #define BOOST_INTRUSIVE_CLANG_INLINE_STD_NS - #pragma GCC diagnostic push - #if defined(__clang__) - #pragma GCC diagnostic ignored "-Wc++11-extensions" - #endif - #define BOOST_INTRUSIVE_STD_NS_BEG _LIBCPP_BEGIN_NAMESPACE_STD - #define BOOST_INTRUSIVE_STD_NS_END _LIBCPP_END_NAMESPACE_STD -#elif defined(BOOST_GNU_STDLIB) && defined(_GLIBCXX_BEGIN_NAMESPACE_VERSION) //GCC >= 4.6 - #define BOOST_INTRUSIVE_STD_NS_BEG namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION - #define BOOST_INTRUSIVE_STD_NS_END _GLIBCXX_END_NAMESPACE_VERSION } // namespace -#elif defined(BOOST_GNU_STDLIB) && defined(_GLIBCXX_BEGIN_NAMESPACE) //GCC >= 4.2 - #define BOOST_INTRUSIVE_STD_NS_BEG _GLIBCXX_BEGIN_NAMESPACE(std) - #define BOOST_INTRUSIVE_STD_NS_END _GLIBCXX_END_NAMESPACE -#else - #define BOOST_INTRUSIVE_STD_NS_BEG namespace std{ - #define BOOST_INTRUSIVE_STD_NS_END } -#endif - -BOOST_INTRUSIVE_STD_NS_BEG +#include <boost/move/detail/std_ns_begin.hpp> +BOOST_MOVE_STD_NS_BEG template<class T> struct less; @@ -55,11 +37,7 @@ struct forward_iterator_tag; struct bidirectional_iterator_tag; struct random_access_iterator_tag; -BOOST_INTRUSIVE_STD_NS_END - -#ifdef BOOST_INTRUSIVE_CLANG_INLINE_STD_NS - #pragma GCC diagnostic pop - #undef BOOST_INTRUSIVE_CLANG_INLINE_STD_NS -#endif //BOOST_INTRUSIVE_CLANG_INLINE_STD_NS +BOOST_MOVE_STD_NS_END +#include <boost/move/detail/std_ns_end.hpp> #endif //#ifndef BOOST_INTRUSIVE_DETAIL_STD_FWD_HPP diff --git a/boost/intrusive/detail/tree_iterator.hpp b/boost/intrusive/detail/tree_iterator.hpp index c2e980d27a..4985c6ce7b 100644 --- a/boost/intrusive/detail/tree_iterator.hpp +++ b/boost/intrusive/detail/tree_iterator.hpp @@ -106,14 +106,23 @@ class tree_iterator return result; } - void go_left() - { members_.nodeptr_ = node_traits::get_left(members_.nodeptr_); } + tree_iterator& go_left() + { + members_.nodeptr_ = node_traits::get_left(members_.nodeptr_); + return static_cast<tree_iterator&> (*this); + } - void go_right() - { members_.nodeptr_ = node_traits::get_right(members_.nodeptr_); } + tree_iterator& go_right() + { + members_.nodeptr_ = node_traits::get_right(members_.nodeptr_); + return static_cast<tree_iterator&> (*this); + } - void go_parent() - { members_.nodeptr_ = node_traits::get_parent(members_.nodeptr_); } + tree_iterator& go_parent() + { + members_.nodeptr_ = node_traits::get_parent(members_.nodeptr_); + return static_cast<tree_iterator&> (*this); + } operator unspecified_bool_type() const { return members_.nodeptr_ ? &tree_iterator::unspecified_bool_type_func : 0; } diff --git a/boost/intrusive/detail/tree_value_compare.hpp b/boost/intrusive/detail/tree_value_compare.hpp index a05741edee..dc554442fe 100644 --- a/boost/intrusive/detail/tree_value_compare.hpp +++ b/boost/intrusive/detail/tree_value_compare.hpp @@ -34,14 +34,25 @@ struct tree_value_compare typedef KeyOfValue key_of_value; typedef Key key_type; + + tree_value_compare() + : base_t() + {} + explicit tree_value_compare(const key_compare &kcomp) : base_t(kcomp) {} - tree_value_compare() - : base_t() + tree_value_compare (const tree_value_compare &x) + : base_t(x.base_t::get()) {} + tree_value_compare &operator=(const tree_value_compare &x) + { this->base_t::get() = x.base_t::get(); return *this; } + + tree_value_compare &operator=(const key_compare &x) + { this->base_t::get() = x; return *this; } + const key_compare &key_comp() const { return static_cast<const key_compare &>(*this); } @@ -54,13 +65,13 @@ struct tree_value_compare {}; template<class U> - typename boost::intrusive::detail::enable_if<is_key<U>, const key_type &>::type - key_forward(const U &key) const + const key_type & key_forward + (const U &key, typename boost::intrusive::detail::enable_if<is_key<U> >::type* = 0) const { return key; } template<class U> - typename boost::intrusive::detail::disable_if<is_key<U>, const key_type &>::type - key_forward(const U &key) const + const key_type & key_forward + (const U &key, typename boost::intrusive::detail::disable_if<is_key<U> >::type* = 0) const { return KeyOfValue()(key); } template<class KeyType, class KeyType2> diff --git a/boost/intrusive/intrusive_fwd.hpp b/boost/intrusive/intrusive_fwd.hpp index b6b14c0698..f51276d636 100644 --- a/boost/intrusive/intrusive_fwd.hpp +++ b/boost/intrusive/intrusive_fwd.hpp @@ -16,7 +16,11 @@ #ifndef BOOST_CONFIG_HPP # include <boost/config.hpp> #endif - +# +#ifndef BOOST_CSTDINT_HPP +# include <boost/cstdint.hpp> +#endif +# #if defined(BOOST_HAS_PRAGMA_ONCE) # pragma once #endif @@ -65,6 +69,14 @@ namespace boost { namespace intrusive { +#if !defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED) +# ifdef BOOST_HAS_INTPTR_T + using ::boost::uintptr_t; +# else + typedef std::size_t uintptr_t; +# endif +#endif + //////////////////////////// // Node algorithms //////////////////////////// diff --git a/boost/intrusive/pointer_plus_bits.hpp b/boost/intrusive/pointer_plus_bits.hpp index 117aff3c58..6168ea8ea4 100644 --- a/boost/intrusive/pointer_plus_bits.hpp +++ b/boost/intrusive/pointer_plus_bits.hpp @@ -64,25 +64,25 @@ struct pointer_plus_bits template<class T, std::size_t NumBits> struct pointer_plus_bits<T*, NumBits> { - static const std::size_t Mask = ((std::size_t(1u) << NumBits) - 1); + static const uintptr_t Mask = uintptr_t((uintptr_t(1u) << NumBits) - 1); typedef T* pointer; static pointer get_pointer(pointer n) - { return pointer(std::size_t(n) & ~Mask); } + { return pointer(uintptr_t(n) & uintptr_t(~Mask)); } static void set_pointer(pointer &n, pointer p) { - BOOST_INTRUSIVE_INVARIANT_ASSERT(0 == (std::size_t(p) & Mask)); - n = pointer(std::size_t(p) | (std::size_t(n) & Mask)); + BOOST_INTRUSIVE_INVARIANT_ASSERT(0 == (uintptr_t(p) & Mask)); + n = pointer(uintptr_t(p) | (uintptr_t(n) & Mask)); } static std::size_t get_bits(pointer n) - { return (std::size_t(n) & Mask); } + { return std::size_t(uintptr_t(n) & Mask); } static void set_bits(pointer &n, std::size_t c) { - BOOST_INTRUSIVE_INVARIANT_ASSERT(c <= Mask); - n = pointer(std::size_t(get_pointer(n)) | c); + BOOST_INTRUSIVE_INVARIANT_ASSERT(uintptr_t(c) <= Mask); + n = pointer(uintptr_t((get_pointer)(n)) | uintptr_t(c)); } }; diff --git a/boost/intrusive/pointer_traits.hpp b/boost/intrusive/pointer_traits.hpp index 24843fddc5..731432b01f 100644 --- a/boost/intrusive/pointer_traits.hpp +++ b/boost/intrusive/pointer_traits.hpp @@ -223,7 +223,7 @@ struct pointer_traits template<class UPtr> static pointer priv_static_cast_from(boost::intrusive::detail::false_, const UPtr &uptr) - { return pointer_to(*static_cast<element_type*>(to_raw_pointer(uptr))); } + { return uptr ? pointer_to(*static_cast<element_type*>(to_raw_pointer(uptr))) : pointer(); } //priv_const_cast_from template<class UPtr> @@ -232,7 +232,7 @@ struct pointer_traits template<class UPtr> static pointer priv_const_cast_from(boost::intrusive::detail::false_, const UPtr &uptr) - { return pointer_to(const_cast<element_type&>(*uptr)); } + { return uptr ? pointer_to(const_cast<element_type&>(*uptr)) : pointer(); } //priv_dynamic_cast_from template<class UPtr> @@ -241,15 +241,7 @@ struct pointer_traits template<class UPtr> static pointer priv_dynamic_cast_from(boost::intrusive::detail::false_, const UPtr &uptr) - { - element_type *p = dynamic_cast<element_type*>(&*uptr); - if(!p){ - return pointer(); - } - else{ - return pointer_to(*p); - } - } + { return uptr ? pointer_to(dynamic_cast<element_type&>(*uptr)) : pointer(); } ///@endcond }; diff --git a/boost/intrusive/rbtree_algorithms.hpp b/boost/intrusive/rbtree_algorithms.hpp index 00d9fe3b18..2a74e1b2cd 100644 --- a/boost/intrusive/rbtree_algorithms.hpp +++ b/boost/intrusive/rbtree_algorithms.hpp @@ -448,6 +448,7 @@ class rbtree_algorithms NodeTraits::set_color(x_parent, NodeTraits::red()); bstree_algo::rotate_left(x_parent, w, NodeTraits::get_parent(x_parent), header); w = NodeTraits::get_right(x_parent); + BOOST_INTRUSIVE_INVARIANT_ASSERT(w); } node_ptr const w_left (NodeTraits::get_left(w)); node_ptr const w_right(NodeTraits::get_right(w)); @@ -463,6 +464,7 @@ class rbtree_algorithms NodeTraits::set_color(w, NodeTraits::red()); bstree_algo::rotate_right(w, w_left, NodeTraits::get_parent(w), header); w = NodeTraits::get_right(x_parent); + BOOST_INTRUSIVE_INVARIANT_ASSERT(w); } NodeTraits::set_color(w, NodeTraits::get_color(x_parent)); NodeTraits::set_color(x_parent, NodeTraits::black()); @@ -481,6 +483,7 @@ class rbtree_algorithms NodeTraits::set_color(x_parent, NodeTraits::red()); bstree_algo::rotate_right(x_parent, w, NodeTraits::get_parent(x_parent), header); w = NodeTraits::get_left(x_parent); + BOOST_INTRUSIVE_INVARIANT_ASSERT(w); } node_ptr const w_left (NodeTraits::get_left(w)); node_ptr const w_right(NodeTraits::get_right(w)); @@ -496,6 +499,7 @@ class rbtree_algorithms NodeTraits::set_color(w, NodeTraits::red()); bstree_algo::rotate_left(w, w_right, NodeTraits::get_parent(w), header); w = NodeTraits::get_left(x_parent); + BOOST_INTRUSIVE_INVARIANT_ASSERT(w); } NodeTraits::set_color(w, NodeTraits::get_color(x_parent)); NodeTraits::set_color(x_parent, NodeTraits::black()); diff --git a/boost/intrusive/set.hpp b/boost/intrusive/set.hpp index ae6a7a0812..f0072eab20 100644 --- a/boost/intrusive/set.hpp +++ b/boost/intrusive/set.hpp @@ -328,7 +328,7 @@ class set_impl //! @copydoc ::boost::intrusive::rbtree::equal_range(const KeyType&,KeyTypeKeyCompare) template<class KeyType, class KeyTypeKeyCompare> std::pair<iterator,iterator> equal_range(const KeyType& key, KeyTypeKeyCompare comp) - { return this->tree_type::lower_bound_range(key, comp); } + { return this->tree_type::equal_range(key, comp); } //! @copydoc ::boost::intrusive::rbtree::equal_range(const key_type &)const std::pair<const_iterator, const_iterator> @@ -339,7 +339,7 @@ class set_impl template<class KeyType, class KeyTypeKeyCompare> std::pair<const_iterator, const_iterator> equal_range(const KeyType& key, KeyTypeKeyCompare comp) const - { return this->tree_type::lower_bound_range(key, comp); } + { return this->tree_type::equal_range(key, comp); } #ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED diff --git a/boost/intrusive/sg_set.hpp b/boost/intrusive/sg_set.hpp index 560845e7a2..e6d4e377d3 100644 --- a/boost/intrusive/sg_set.hpp +++ b/boost/intrusive/sg_set.hpp @@ -326,7 +326,7 @@ class sg_set_impl //! @copydoc ::boost::intrusive::rbtree::equal_range(const KeyType&,KeyTypeKeyCompare) template<class KeyType, class KeyTypeKeyCompare> std::pair<iterator,iterator> equal_range(const KeyType& key, KeyTypeKeyCompare comp) - { return this->tree_type::lower_bound_range(key, comp); } + { return this->tree_type::equal_range(key, comp); } //! @copydoc ::boost::intrusive::rbtree::equal_range(const key_type &)const std::pair<const_iterator, const_iterator> @@ -337,7 +337,7 @@ class sg_set_impl template<class KeyType, class KeyTypeKeyCompare> std::pair<const_iterator, const_iterator> equal_range(const KeyType& key, KeyTypeKeyCompare comp) const - { return this->tree_type::lower_bound_range(key, comp); } + { return this->tree_type::equal_range(key, comp); } #ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED diff --git a/boost/intrusive/sgtree.hpp b/boost/intrusive/sgtree.hpp index dc84c80462..b4c4cdec1a 100644 --- a/boost/intrusive/sgtree.hpp +++ b/boost/intrusive/sgtree.hpp @@ -826,18 +826,17 @@ class sgtree_impl //! <b>Complexity</b>: Linear to the elements in the subtree. void balance_factor(float new_alpha) { - BOOST_INTRUSIVE_INVARIANT_ASSERT((new_alpha > 0.5f && new_alpha < 1.0f)); - if(new_alpha < 0.5f && new_alpha >= 1.0f) return; - //The alpha factor CAN't be changed if the fixed, floating operation-less //1/sqrt(2) alpha factor option is activated BOOST_STATIC_ASSERT((floating_point)); - float old_alpha = this->get_alpha_traits().get_alpha(); - this->get_alpha_traits().set_alpha(new_alpha); - - if(new_alpha < old_alpha){ - this->max_tree_size_ = this->size(); - this->rebalance(); + BOOST_INTRUSIVE_INVARIANT_ASSERT((new_alpha > 0.5f && new_alpha < 1.0f)); + if(new_alpha >= 0.5f && new_alpha < 1.0f){ + float old_alpha = this->get_alpha_traits().get_alpha(); + this->get_alpha_traits().set_alpha(new_alpha); + if(new_alpha < old_alpha){ + this->max_tree_size_ = this->size(); + this->rebalance(); + } } } diff --git a/boost/intrusive/splay_set.hpp b/boost/intrusive/splay_set.hpp index eea19d7999..3d43215023 100644 --- a/boost/intrusive/splay_set.hpp +++ b/boost/intrusive/splay_set.hpp @@ -333,7 +333,7 @@ class splay_set_impl //! @copydoc ::boost::intrusive::rbtree::equal_range(const KeyType&,KeyTypeKeyCompare) template<class KeyType, class KeyTypeKeyCompare> std::pair<iterator,iterator> equal_range(const KeyType& key, KeyTypeKeyCompare comp) - { return this->tree_type::lower_bound_range(key, comp); } + { return this->tree_type::equal_range(key, comp); } //! @copydoc ::boost::intrusive::rbtree::equal_range(const key_type &)const std::pair<const_iterator, const_iterator> @@ -344,7 +344,7 @@ class splay_set_impl template<class KeyType, class KeyTypeKeyCompare> std::pair<const_iterator, const_iterator> equal_range(const KeyType& key, KeyTypeKeyCompare comp) const - { return this->tree_type::lower_bound_range(key, comp); } + { return this->tree_type::equal_range(key, comp); } #ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED diff --git a/boost/intrusive/treap_set.hpp b/boost/intrusive/treap_set.hpp index 188c80fdce..60cf449147 100644 --- a/boost/intrusive/treap_set.hpp +++ b/boost/intrusive/treap_set.hpp @@ -375,7 +375,7 @@ class treap_set_impl //! @copydoc ::boost::intrusive::rbtree::equal_range(const KeyType&,KeyTypeKeyCompare) template<class KeyType, class KeyTypeKeyCompare> std::pair<iterator,iterator> equal_range(const KeyType& key, KeyTypeKeyCompare comp) - { return this->tree_type::lower_bound_range(key, comp); } + { return this->tree_type::equal_range(key, comp); } //! @copydoc ::boost::intrusive::rbtree::equal_range(const key_type &)const std::pair<const_iterator, const_iterator> @@ -386,7 +386,7 @@ class treap_set_impl template<class KeyType, class KeyTypeKeyCompare> std::pair<const_iterator, const_iterator> equal_range(const KeyType& key, KeyTypeKeyCompare comp) const - { return this->tree_type::lower_bound_range(key, comp); } + { return this->tree_type::equal_range(key, comp); } #ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED |