Warning, file /include/boost/intrusive/detail/list_iterator.hpp was not indexed
or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014 #ifndef BOOST_INTRUSIVE_LIST_ITERATOR_HPP
0015 #define BOOST_INTRUSIVE_LIST_ITERATOR_HPP
0016
0017 #ifndef BOOST_CONFIG_HPP
0018 # include <boost/config.hpp>
0019 #endif
0020
0021 #if defined(BOOST_HAS_PRAGMA_ONCE)
0022 # pragma once
0023 #endif
0024
0025 #include <boost/intrusive/detail/workaround.hpp>
0026 #include <boost/intrusive/detail/std_fwd.hpp>
0027 #include <boost/intrusive/detail/iiterator.hpp>
0028 #include <boost/intrusive/detail/mpl.hpp>
0029
0030 namespace boost {
0031 namespace intrusive {
0032
0033
0034
0035 template<class ValueTraits, bool IsConst>
0036 class list_iterator
0037 {
0038 private:
0039 typedef iiterator
0040 <ValueTraits, IsConst, std::bidirectional_iterator_tag> types_t;
0041
0042 static const bool stateful_value_traits = types_t::stateful_value_traits;
0043
0044 typedef ValueTraits value_traits;
0045 typedef typename types_t::node_traits node_traits;
0046
0047 typedef typename types_t::node node;
0048 typedef typename types_t::node_ptr node_ptr;
0049 typedef typename types_t::const_value_traits_ptr const_value_traits_ptr;
0050 class nat;
0051 typedef typename
0052 detail::if_c< IsConst
0053 , list_iterator<value_traits, false>
0054 , nat>::type nonconst_iterator;
0055
0056 public:
0057 typedef typename types_t::iterator_type::difference_type difference_type;
0058 typedef typename types_t::iterator_type::value_type value_type;
0059 typedef typename types_t::iterator_type::pointer pointer;
0060 typedef typename types_t::iterator_type::reference reference;
0061 typedef typename types_t::iterator_type::iterator_category iterator_category;
0062
0063 BOOST_INTRUSIVE_FORCEINLINE list_iterator()
0064 {}
0065
0066 BOOST_INTRUSIVE_FORCEINLINE explicit list_iterator(node_ptr nodeptr, const_value_traits_ptr traits_ptr)
0067 : members_(nodeptr, traits_ptr)
0068 {}
0069
0070 BOOST_INTRUSIVE_FORCEINLINE list_iterator(const list_iterator &other)
0071 : members_(other.pointed_node(), other.get_value_traits())
0072 {}
0073
0074 BOOST_INTRUSIVE_FORCEINLINE list_iterator(const nonconst_iterator &other)
0075 : members_(other.pointed_node(), other.get_value_traits())
0076 {}
0077
0078 BOOST_INTRUSIVE_FORCEINLINE list_iterator &operator=(const list_iterator &other)
0079 { members_.nodeptr_ = other.members_.nodeptr_; return *this; }
0080
0081 BOOST_INTRUSIVE_FORCEINLINE node_ptr pointed_node() const
0082 { return members_.nodeptr_; }
0083
0084 BOOST_INTRUSIVE_FORCEINLINE list_iterator &operator=(node_ptr nodeptr)
0085 { members_.nodeptr_ = nodeptr; return *this; }
0086
0087 BOOST_INTRUSIVE_FORCEINLINE const_value_traits_ptr get_value_traits() const
0088 { return members_.get_ptr(); }
0089
0090 public:
0091 BOOST_INTRUSIVE_FORCEINLINE list_iterator& operator++()
0092 {
0093 node_ptr p = node_traits::get_next(members_.nodeptr_);
0094 members_.nodeptr_ = p;
0095 return static_cast<list_iterator&> (*this);
0096 }
0097
0098 BOOST_INTRUSIVE_FORCEINLINE list_iterator operator++(int)
0099 {
0100 list_iterator result (*this);
0101 members_.nodeptr_ = node_traits::get_next(members_.nodeptr_);
0102 return result;
0103 }
0104
0105 BOOST_INTRUSIVE_FORCEINLINE list_iterator& operator--()
0106 {
0107 members_.nodeptr_ = node_traits::get_previous(members_.nodeptr_);
0108 return static_cast<list_iterator&> (*this);
0109 }
0110
0111 BOOST_INTRUSIVE_FORCEINLINE list_iterator operator--(int)
0112 {
0113 list_iterator result (*this);
0114 members_.nodeptr_ = node_traits::get_previous(members_.nodeptr_);
0115 return result;
0116 }
0117
0118 BOOST_INTRUSIVE_FORCEINLINE friend bool operator== (const list_iterator& l, const list_iterator& r)
0119 { return l.pointed_node() == r.pointed_node(); }
0120
0121 BOOST_INTRUSIVE_FORCEINLINE friend bool operator!= (const list_iterator& l, const list_iterator& r)
0122 { return !(l == r); }
0123
0124 BOOST_INTRUSIVE_FORCEINLINE reference operator*() const
0125 { return *operator->(); }
0126
0127 BOOST_INTRUSIVE_FORCEINLINE pointer operator->() const
0128 { return this->operator_arrow(detail::bool_<stateful_value_traits>()); }
0129
0130 BOOST_INTRUSIVE_FORCEINLINE list_iterator<ValueTraits, false> unconst() const
0131 { return list_iterator<ValueTraits, false>(this->pointed_node(), this->get_value_traits()); }
0132
0133 private:
0134 BOOST_INTRUSIVE_FORCEINLINE pointer operator_arrow(detail::false_) const
0135 { return ValueTraits::to_value_ptr(members_.nodeptr_); }
0136
0137 BOOST_INTRUSIVE_FORCEINLINE pointer operator_arrow(detail::true_) const
0138 { return this->get_value_traits()->to_value_ptr(members_.nodeptr_); }
0139
0140 iiterator_members<node_ptr, const_value_traits_ptr, stateful_value_traits> members_;
0141 };
0142
0143 }
0144 }
0145
0146 #endif