diff options
author | DongHun Kwak <dh0128.kwak@samsung.com> | 2019-12-05 15:22:41 +0900 |
---|---|---|
committer | DongHun Kwak <dh0128.kwak@samsung.com> | 2019-12-05 15:22:41 +0900 |
commit | 3c1df2168531ad5580076ae08d529054689aeedd (patch) | |
tree | 941aff6f86393eecacddfec252a8508c7e8351c9 /boost/intrusive/detail | |
parent | d6a306e745acfee00e81ccaf3324a2a03516db41 (diff) | |
download | boost-3c1df2168531ad5580076ae08d529054689aeedd.tar.gz boost-3c1df2168531ad5580076ae08d529054689aeedd.tar.bz2 boost-3c1df2168531ad5580076ae08d529054689aeedd.zip |
Imported Upstream version 1.70.0upstream/1.70.0
Diffstat (limited to 'boost/intrusive/detail')
-rw-r--r-- | boost/intrusive/detail/ebo_functor_holder.hpp | 6 | ||||
-rw-r--r-- | boost/intrusive/detail/generic_hook.hpp | 18 | ||||
-rw-r--r-- | boost/intrusive/detail/hashtable_node.hpp | 27 | ||||
-rw-r--r-- | boost/intrusive/detail/hook_traits.hpp | 16 | ||||
-rw-r--r-- | boost/intrusive/detail/iterator.hpp | 20 | ||||
-rw-r--r-- | boost/intrusive/detail/key_nodeptr_comp.hpp | 2 | ||||
-rw-r--r-- | boost/intrusive/detail/list_iterator.hpp | 18 | ||||
-rw-r--r-- | boost/intrusive/detail/math.hpp | 4 | ||||
-rw-r--r-- | boost/intrusive/detail/mpl.hpp | 1 | ||||
-rw-r--r-- | boost/intrusive/detail/slist_iterator.hpp | 14 | ||||
-rw-r--r-- | boost/intrusive/detail/tree_iterator.hpp | 34 | ||||
-rw-r--r-- | boost/intrusive/detail/workaround.hpp | 2 |
12 files changed, 108 insertions, 54 deletions
diff --git a/boost/intrusive/detail/ebo_functor_holder.hpp b/boost/intrusive/detail/ebo_functor_holder.hpp index 27415c1170..8883166783 100644 --- a/boost/intrusive/detail/ebo_functor_holder.hpp +++ b/boost/intrusive/detail/ebo_functor_holder.hpp @@ -158,7 +158,7 @@ template<typename T> struct is_unary_or_binary_function : is_unary_or_binary_function_impl<T> {}; -template<typename T, bool = is_unary_or_binary_function<T>::value> +template<typename T, typename Tag = void, bool = is_unary_or_binary_function<T>::value> class ebo_functor_holder { BOOST_COPYABLE_AND_MOVABLE(ebo_functor_holder) @@ -222,8 +222,8 @@ class ebo_functor_holder T t_; }; -template<typename T> -class ebo_functor_holder<T, false> +template<typename T, typename Tag> +class ebo_functor_holder<T, Tag, false> : public T { BOOST_COPYABLE_AND_MOVABLE(ebo_functor_holder) diff --git a/boost/intrusive/detail/generic_hook.hpp b/boost/intrusive/detail/generic_hook.hpp index 13421b8805..eff7fa0472 100644 --- a/boost/intrusive/detail/generic_hook.hpp +++ b/boost/intrusive/detail/generic_hook.hpp @@ -161,52 +161,52 @@ class generic_hook < NodeTraits , Tag, LinkMode, BaseHookType> hooktags; - node_ptr this_ptr() + BOOST_INTRUSIVE_FORCEINLINE node_ptr this_ptr() { return pointer_traits<node_ptr>::pointer_to(static_cast<node&>(*this)); } - const_node_ptr this_ptr() const + BOOST_INTRUSIVE_FORCEINLINE const_node_ptr this_ptr() const { return pointer_traits<const_node_ptr>::pointer_to(static_cast<const node&>(*this)); } public: /// @endcond - generic_hook() + BOOST_INTRUSIVE_FORCEINLINE generic_hook() { if(hooktags::safemode_or_autounlink){ node_algorithms::init(this->this_ptr()); } } - generic_hook(const generic_hook& ) + BOOST_INTRUSIVE_FORCEINLINE generic_hook(const generic_hook& ) { if(hooktags::safemode_or_autounlink){ node_algorithms::init(this->this_ptr()); } } - generic_hook& operator=(const generic_hook& ) + BOOST_INTRUSIVE_FORCEINLINE generic_hook& operator=(const generic_hook& ) { return *this; } - ~generic_hook() + BOOST_INTRUSIVE_FORCEINLINE ~generic_hook() { destructor_impl (*this, detail::link_dispatch<hooktags::link_mode>()); } - void swap_nodes(generic_hook &other) + BOOST_INTRUSIVE_FORCEINLINE void swap_nodes(generic_hook &other) { node_algorithms::swap_nodes (this->this_ptr(), other.this_ptr()); } - bool is_linked() const + BOOST_INTRUSIVE_FORCEINLINE bool is_linked() const { //is_linked() can be only used in safe-mode or auto-unlink BOOST_STATIC_ASSERT(( hooktags::safemode_or_autounlink )); return !node_algorithms::unique(this->this_ptr()); } - void unlink() + BOOST_INTRUSIVE_FORCEINLINE void unlink() { BOOST_STATIC_ASSERT(( (int)hooktags::link_mode == (int)auto_unlink )); node_ptr n(this->this_ptr()); diff --git a/boost/intrusive/detail/hashtable_node.hpp b/boost/intrusive/detail/hashtable_node.hpp index d3b11d1b22..913c38da70 100644 --- a/boost/intrusive/detail/hashtable_node.hpp +++ b/boost/intrusive/detail/hashtable_node.hpp @@ -34,7 +34,6 @@ namespace boost { namespace intrusive { -namespace detail { template <class Slist> struct bucket_impl : public Slist @@ -149,8 +148,6 @@ struct get_slist_impl {}; }; -} //namespace detail { - template<class BucketValueTraits, bool IsConst> class hashtable_iterator { @@ -169,17 +166,22 @@ class hashtable_iterator private: typedef typename value_traits::node_traits node_traits; typedef typename node_traits::node_ptr node_ptr; - typedef typename detail::get_slist_impl - < typename detail::reduced_slist_node_traits + typedef typename get_slist_impl + < typename reduced_slist_node_traits <node_traits>::type >::type slist_impl; typedef typename slist_impl::iterator siterator; typedef typename slist_impl::const_iterator const_siterator; - typedef detail::bucket_impl<slist_impl> bucket_type; + typedef bucket_impl<slist_impl> bucket_type; typedef typename pointer_traits <pointer>::template rebind_pointer < const BucketValueTraits >::type const_bucketvaltraits_ptr; typedef typename slist_impl::size_type size_type; + class nat; + typedef typename + detail::if_c< IsConst + , hashtable_iterator<BucketValueTraits, false> + , nat>::type nonconst_iterator; BOOST_INTRUSIVE_FORCEINLINE static node_ptr downcast_bucket(typename bucket_type::node_ptr p) { @@ -193,12 +195,16 @@ class hashtable_iterator : slist_it_() //Value initialization to achieve "null iterators" (N3644) {} - explicit hashtable_iterator(siterator ptr, const BucketValueTraits *cont) + BOOST_INTRUSIVE_FORCEINLINE explicit hashtable_iterator(siterator ptr, const BucketValueTraits *cont) : slist_it_ (ptr) , traitsptr_ (cont ? pointer_traits<const_bucketvaltraits_ptr>::pointer_to(*cont) : const_bucketvaltraits_ptr() ) {} - BOOST_INTRUSIVE_FORCEINLINE hashtable_iterator(const hashtable_iterator<BucketValueTraits, false> &other) + BOOST_INTRUSIVE_FORCEINLINE hashtable_iterator(const hashtable_iterator &other) + : slist_it_(other.slist_it()), traitsptr_(other.get_bucket_value_traits()) + {} + + BOOST_INTRUSIVE_FORCEINLINE hashtable_iterator(const nonconst_iterator &other) : slist_it_(other.slist_it()), traitsptr_(other.get_bucket_value_traits()) {} @@ -211,7 +217,10 @@ class hashtable_iterator BOOST_INTRUSIVE_FORCEINLINE hashtable_iterator& operator++() { this->increment(); return *this; } - hashtable_iterator operator++(int) + BOOST_INTRUSIVE_FORCEINLINE hashtable_iterator &operator=(const hashtable_iterator &other) + { slist_it_ = other.slist_it(); traitsptr_ = other.get_bucket_value_traits(); return *this; } + + BOOST_INTRUSIVE_FORCEINLINE hashtable_iterator operator++(int) { hashtable_iterator result (*this); this->increment(); diff --git a/boost/intrusive/detail/hook_traits.hpp b/boost/intrusive/detail/hook_traits.hpp index 7a6f206ca2..7f7dc27e0e 100644 --- a/boost/intrusive/detail/hook_traits.hpp +++ b/boost/intrusive/detail/hook_traits.hpp @@ -57,26 +57,34 @@ struct bhtraits_base BOOST_INTRUSIVE_FORCEINLINE static pointer to_value_ptr(const node_ptr & n) { - return pointer_traits<pointer>::pointer_to + pointer p = pointer_traits<pointer>::pointer_to (static_cast<reference>(static_cast<node_holder_reference>(*n))); + BOOST_ASSERT(!!p); + return p; } BOOST_INTRUSIVE_FORCEINLINE static const_pointer to_value_ptr(const const_node_ptr & n) { - return pointer_traits<const_pointer>::pointer_to + const_pointer p = pointer_traits<const_pointer>::pointer_to (static_cast<const_reference>(static_cast<const_node_holder_reference>(*n))); + BOOST_ASSERT(!!p); + return p; } BOOST_INTRUSIVE_FORCEINLINE static node_ptr to_node_ptr(reference value) { - return pointer_traits<node_ptr>::pointer_to + node_ptr p = pointer_traits<node_ptr>::pointer_to (static_cast<node_reference>(static_cast<node_holder_reference>(value))); + BOOST_ASSERT(!!p); + return p; } BOOST_INTRUSIVE_FORCEINLINE static const_node_ptr to_node_ptr(const_reference value) { - return pointer_traits<const_node_ptr>::pointer_to + const_node_ptr p = pointer_traits<const_node_ptr>::pointer_to (static_cast<const_node_reference>(static_cast<const_node_holder_reference>(value))); + BOOST_ASSERT(!!p); + return p; } }; diff --git a/boost/intrusive/detail/iterator.hpp b/boost/intrusive/detail/iterator.hpp index c25be430a2..41ffca1255 100644 --- a/boost/intrusive/detail/iterator.hpp +++ b/boost/intrusive/detail/iterator.hpp @@ -147,7 +147,7 @@ BOOST_INTRUSIVE_FORCEINLINE typename iterator_enable_if_tag<InputIt, std::input_ iterator_advance(InputIt& it, Distance n) { while(n--) - ++it; + ++it; } template<class InputIt, class Distance> @@ -155,7 +155,7 @@ typename iterator_enable_if_tag<InputIt, std::forward_iterator_tag>::type iterator_advance(InputIt& it, Distance n) { while(n--) - ++it; + ++it; } template<class InputIt, class Distance> @@ -163,9 +163,9 @@ BOOST_INTRUSIVE_FORCEINLINE typename iterator_enable_if_tag<InputIt, std::bidire iterator_advance(InputIt& it, Distance n) { for (; 0 < n; --n) - ++it; + ++it; for (; n < 0; ++n) - --it; + --it; } template<class InputIt, class Distance> @@ -181,7 +181,7 @@ BOOST_INTRUSIVE_FORCEINLINE typename iterator_enable_if_convertible_tag iterator_advance(InputIt& it, Distance n) { while(n--) - ++it; + ++it; } template<class InputIt, class Distance> @@ -190,7 +190,7 @@ BOOST_INTRUSIVE_FORCEINLINE typename iterator_enable_if_convertible_tag iterator_advance(InputIt& it, Distance n) { while(n--) - ++it; + ++it; } template<class InputIt, class Distance> @@ -199,7 +199,7 @@ BOOST_INTRUSIVE_FORCEINLINE typename iterator_enable_if_convertible_tag iterator_advance(InputIt& it, Distance n) { while(n--) - ++it; + ++it; } template<class InputIt, class Distance> @@ -208,9 +208,9 @@ BOOST_INTRUSIVE_FORCEINLINE typename iterator_enable_if_convertible_tag iterator_advance(InputIt& it, Distance n) { for (; 0 < n; --n) - ++it; + ++it; for (; n < 0; ++n) - --it; + --it; } class fake{}; @@ -233,7 +233,7 @@ typename iterator_disable_if_tag_difference_type { typename iterator_traits<InputIt>::difference_type off = 0; while(first != last){ - ++off; + ++off; ++first; } return off; diff --git a/boost/intrusive/detail/key_nodeptr_comp.hpp b/boost/intrusive/detail/key_nodeptr_comp.hpp index bdc025e5ab..1029a3404a 100644 --- a/boost/intrusive/detail/key_nodeptr_comp.hpp +++ b/boost/intrusive/detail/key_nodeptr_comp.hpp @@ -78,7 +78,7 @@ public: static const bool value = same_type || is_convertible<P1, const_node_ptr>::value; }; - base_t base() const + BOOST_INTRUSIVE_FORCEINLINE base_t base() const { return static_cast<const base_t&>(*this); } BOOST_INTRUSIVE_FORCEINLINE key_nodeptr_comp(KeyTypeKeyCompare kcomp, const ValueTraits *traits) diff --git a/boost/intrusive/detail/list_iterator.hpp b/boost/intrusive/detail/list_iterator.hpp index 3aae2d5a54..880b6a9847 100644 --- a/boost/intrusive/detail/list_iterator.hpp +++ b/boost/intrusive/detail/list_iterator.hpp @@ -47,6 +47,11 @@ class list_iterator typedef typename types_t::node node; typedef typename types_t::node_ptr node_ptr; typedef typename types_t::const_value_traits_ptr const_value_traits_ptr; + class nat; + typedef typename + detail::if_c< IsConst + , list_iterator<value_traits, false> + , nat>::type nonconst_iterator; public: typedef typename types_t::iterator_type::difference_type difference_type; @@ -62,15 +67,22 @@ class list_iterator : members_(nodeptr, traits_ptr) {} - BOOST_INTRUSIVE_FORCEINLINE list_iterator(list_iterator<ValueTraits, false> const& other) + BOOST_INTRUSIVE_FORCEINLINE list_iterator(const list_iterator &other) : members_(other.pointed_node(), other.get_value_traits()) {} + BOOST_INTRUSIVE_FORCEINLINE list_iterator(const nonconst_iterator &other) + : members_(other.pointed_node(), other.get_value_traits()) + {} + + BOOST_INTRUSIVE_FORCEINLINE list_iterator &operator=(const list_iterator &other) + { members_.nodeptr_ = other.members_.nodeptr_; return *this; } + BOOST_INTRUSIVE_FORCEINLINE node_ptr pointed_node() const { return members_.nodeptr_; } BOOST_INTRUSIVE_FORCEINLINE list_iterator &operator=(const node_ptr &node) - { members_.nodeptr_ = node; return static_cast<list_iterator&>(*this); } + { members_.nodeptr_ = node; return *this; } BOOST_INTRUSIVE_FORCEINLINE const_value_traits_ptr get_value_traits() const { return members_.get_ptr(); } @@ -115,7 +127,7 @@ class list_iterator BOOST_INTRUSIVE_FORCEINLINE pointer operator->() const { return this->operator_arrow(detail::bool_<stateful_value_traits>()); } - list_iterator<ValueTraits, false> unconst() const + BOOST_INTRUSIVE_FORCEINLINE list_iterator<ValueTraits, false> unconst() const { return list_iterator<ValueTraits, false>(this->pointed_node(), this->get_value_traits()); } private: diff --git a/boost/intrusive/detail/math.hpp b/boost/intrusive/detail/math.hpp index 4901053cb3..200f8b8776 100644 --- a/boost/intrusive/detail/math.hpp +++ b/boost/intrusive/detail/math.hpp @@ -262,7 +262,7 @@ template<class SizeType, class Enabler = void > struct sqrt2_pow_max; template <class SizeType> -struct sqrt2_pow_max<SizeType, typename enable_if< numbits_eq<SizeType, 32> >::type> +struct sqrt2_pow_max<SizeType, typename voider<typename enable_if< numbits_eq<SizeType, 32> >::type>::type> { static const SizeType value = 0xb504f334; static const std::size_t pow = 31; @@ -271,7 +271,7 @@ struct sqrt2_pow_max<SizeType, typename enable_if< numbits_eq<SizeType, 32> >::t #ifndef BOOST_NO_INT64_T template <class SizeType> -struct sqrt2_pow_max<SizeType, typename enable_if< numbits_eq<SizeType, 64> >::type> +struct sqrt2_pow_max<SizeType, typename voider<typename enable_if< numbits_eq<SizeType, 64> >::type>::type> { static const SizeType value = 0xb504f333f9de6484ull; static const std::size_t pow = 63; diff --git a/boost/intrusive/detail/mpl.hpp b/boost/intrusive/detail/mpl.hpp index 1523088161..935c04c282 100644 --- a/boost/intrusive/detail/mpl.hpp +++ b/boost/intrusive/detail/mpl.hpp @@ -40,6 +40,7 @@ using boost::move_detail::remove_pointer; using boost::move_detail::add_pointer; using boost::move_detail::true_type; using boost::move_detail::false_type; +using boost::move_detail::voider; using boost::move_detail::enable_if_c; using boost::move_detail::enable_if; using boost::move_detail::disable_if_c; diff --git a/boost/intrusive/detail/slist_iterator.hpp b/boost/intrusive/detail/slist_iterator.hpp index 96a5ac0191..9e72af9f39 100644 --- a/boost/intrusive/detail/slist_iterator.hpp +++ b/boost/intrusive/detail/slist_iterator.hpp @@ -49,6 +49,11 @@ class slist_iterator typedef typename types_t::node node; typedef typename types_t::node_ptr node_ptr; typedef typename types_t::const_value_traits_ptr const_value_traits_ptr; + class nat; + typedef typename + detail::if_c< IsConst + , slist_iterator<value_traits, false> + , nat>::type nonconst_iterator; public: typedef typename types_t::iterator_type::difference_type difference_type; @@ -64,10 +69,17 @@ class slist_iterator : members_(nodeptr, traits_ptr) {} - BOOST_INTRUSIVE_FORCEINLINE slist_iterator(slist_iterator<ValueTraits, false> const& other) + BOOST_INTRUSIVE_FORCEINLINE slist_iterator(const slist_iterator &other) : members_(other.pointed_node(), other.get_value_traits()) {} + BOOST_INTRUSIVE_FORCEINLINE slist_iterator(const nonconst_iterator &other) + : members_(other.pointed_node(), other.get_value_traits()) + {} + + BOOST_INTRUSIVE_FORCEINLINE slist_iterator &operator=(const slist_iterator &other) + { members_.nodeptr_ = other.members_.nodeptr_; return *this; } + BOOST_INTRUSIVE_FORCEINLINE node_ptr pointed_node() const { return members_.nodeptr_; } diff --git a/boost/intrusive/detail/tree_iterator.hpp b/boost/intrusive/detail/tree_iterator.hpp index a4bbc1b066..41988cf180 100644 --- a/boost/intrusive/detail/tree_iterator.hpp +++ b/boost/intrusive/detail/tree_iterator.hpp @@ -55,6 +55,11 @@ class tree_iterator void unspecified_bool_type_func() const {} typedef void (tree_iterator::*unspecified_bool_type)() const; + class nat; + typedef typename + detail::if_c< IsConst + , tree_iterator<value_traits, false> + , nat>::type nonconst_iterator; public: typedef typename types_t::iterator_type::difference_type difference_type; @@ -70,21 +75,28 @@ class tree_iterator : members_(nodeptr, traits_ptr) {} - BOOST_INTRUSIVE_FORCEINLINE tree_iterator(tree_iterator<value_traits, false> const& other) + BOOST_INTRUSIVE_FORCEINLINE tree_iterator(const tree_iterator &other) : members_(other.pointed_node(), other.get_value_traits()) {} - BOOST_INTRUSIVE_FORCEINLINE node_ptr pointed_node() const - { return members_.nodeptr_; } + BOOST_INTRUSIVE_FORCEINLINE tree_iterator(const nonconst_iterator &other) + : members_(other.pointed_node(), other.get_value_traits()) + {} + + BOOST_INTRUSIVE_FORCEINLINE tree_iterator &operator=(const tree_iterator &other) + { members_.nodeptr_ = other.members_.nodeptr_; return *this; } BOOST_INTRUSIVE_FORCEINLINE tree_iterator &operator=(const node_ptr &nodeptr) - { members_.nodeptr_ = nodeptr; return static_cast<tree_iterator&>(*this); } + { members_.nodeptr_ = nodeptr; return *this; } + + BOOST_INTRUSIVE_FORCEINLINE node_ptr pointed_node() const + { return members_.nodeptr_; } public: - tree_iterator& operator++() + BOOST_INTRUSIVE_FORCEINLINE tree_iterator& operator++() { members_.nodeptr_ = node_algorithms::next_node(members_.nodeptr_); - return static_cast<tree_iterator&> (*this); + return *this; } tree_iterator operator++(int) @@ -94,10 +106,10 @@ class tree_iterator return result; } - tree_iterator& operator--() + BOOST_INTRUSIVE_FORCEINLINE tree_iterator& operator--() { members_.nodeptr_ = node_algorithms::prev_node(members_.nodeptr_); - return static_cast<tree_iterator&> (*this); + return *this; } tree_iterator operator--(int) @@ -110,19 +122,19 @@ class tree_iterator BOOST_INTRUSIVE_FORCEINLINE tree_iterator& go_left() { members_.nodeptr_ = node_traits::get_left(members_.nodeptr_); - return static_cast<tree_iterator&> (*this); + return *this; } BOOST_INTRUSIVE_FORCEINLINE tree_iterator& go_right() { members_.nodeptr_ = node_traits::get_right(members_.nodeptr_); - return static_cast<tree_iterator&> (*this); + return *this; } BOOST_INTRUSIVE_FORCEINLINE tree_iterator& go_parent() { members_.nodeptr_ = node_traits::get_parent(members_.nodeptr_); - return static_cast<tree_iterator&> (*this); + return *this; } BOOST_INTRUSIVE_FORCEINLINE operator unspecified_bool_type() const diff --git a/boost/intrusive/detail/workaround.hpp b/boost/intrusive/detail/workaround.hpp index 594ac0b2e5..a9e157077a 100644 --- a/boost/intrusive/detail/workaround.hpp +++ b/boost/intrusive/detail/workaround.hpp @@ -34,7 +34,7 @@ #define BOOST_INTRUSIVE_I , #define BOOST_INTRUSIVE_DOCIGN(T1) T1 -#define BOOST_INTRUSIVE_DISABLE_FORCEINLINE +//#define BOOST_INTRUSIVE_DISABLE_FORCEINLINE #if defined(BOOST_INTRUSIVE_DISABLE_FORCEINLINE) #define BOOST_INTRUSIVE_FORCEINLINE inline |