diff options
Diffstat (limited to 'boost/intrusive/detail/tree_iterator.hpp')
-rw-r--r-- | boost/intrusive/detail/tree_iterator.hpp | 34 |
1 files changed, 23 insertions, 11 deletions
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 |