File indexing completed on 2025-07-14 08:34:40
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014 #ifndef BOOST_INTRUSIVE_SLIST_ITERATOR_HPP
0015 #define BOOST_INTRUSIVE_SLIST_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/config_begin.hpp>
0026 #include <boost/intrusive/detail/workaround.hpp>
0027 #include <boost/intrusive/detail/std_fwd.hpp>
0028 #include <boost/intrusive/detail/iiterator.hpp>
0029 #include <boost/intrusive/detail/mpl.hpp>
0030
0031 namespace boost {
0032 namespace intrusive {
0033
0034
0035
0036
0037 template<class ValueTraits, bool IsConst>
0038 class slist_iterator
0039 {
0040 private:
0041 typedef iiterator
0042 <ValueTraits, IsConst, std::forward_iterator_tag> types_t;
0043
0044 static const bool stateful_value_traits = types_t::stateful_value_traits;
0045
0046 typedef ValueTraits value_traits;
0047 typedef typename types_t::node_traits node_traits;
0048
0049 typedef typename types_t::node node;
0050 typedef typename types_t::node_ptr node_ptr;
0051 typedef typename types_t::const_value_traits_ptr const_value_traits_ptr;
0052 class nat;
0053 typedef typename
0054 detail::if_c< IsConst
0055 , slist_iterator<value_traits, false>
0056 , nat>::type nonconst_iterator;
0057
0058 public:
0059 typedef typename types_t::iterator_type::difference_type difference_type;
0060 typedef typename types_t::iterator_type::value_type value_type;
0061 typedef typename types_t::iterator_type::pointer pointer;
0062 typedef typename types_t::iterator_type::reference reference;
0063 typedef typename types_t::iterator_type::iterator_category iterator_category;
0064
0065 inline slist_iterator()
0066 {}
0067
0068 inline slist_iterator(node_ptr nodeptr, const_value_traits_ptr traits_ptr)
0069 : members_(nodeptr, traits_ptr)
0070 {}
0071
0072 inline explicit slist_iterator(node_ptr nodeptr)
0073 : members_(nodeptr, const_value_traits_ptr())
0074 { BOOST_INTRUSIVE_STATIC_ASSERT((stateful_value_traits == false)); }
0075
0076 inline slist_iterator(const slist_iterator &other)
0077 : members_(other.pointed_node(), other.get_value_traits())
0078 {}
0079
0080 inline slist_iterator(const nonconst_iterator &other)
0081 : members_(other.pointed_node(), other.get_value_traits())
0082 {}
0083
0084 inline slist_iterator &operator=(const slist_iterator &other)
0085 { members_.nodeptr_ = other.members_.nodeptr_; return *this; }
0086
0087 inline node_ptr pointed_node() const
0088 { return members_.nodeptr_; }
0089
0090 inline slist_iterator &operator=(node_ptr n)
0091 { members_.nodeptr_ = n; return static_cast<slist_iterator&>(*this); }
0092
0093 inline const_value_traits_ptr get_value_traits() const
0094 { return members_.get_ptr(); }
0095
0096 inline bool operator!() const
0097 { return !members_.nodeptr_; }
0098
0099 public:
0100 inline slist_iterator& operator++()
0101 {
0102 members_.nodeptr_ = node_traits::get_next(members_.nodeptr_);
0103 return static_cast<slist_iterator&> (*this);
0104 }
0105
0106 inline slist_iterator operator++(int)
0107 {
0108 slist_iterator result (*this);
0109 members_.nodeptr_ = node_traits::get_next(members_.nodeptr_);
0110 return result;
0111 }
0112
0113 inline friend bool operator== (const slist_iterator& l, const slist_iterator& r)
0114 { return l.pointed_node() == r.pointed_node(); }
0115
0116 inline friend bool operator!= (const slist_iterator& l, const slist_iterator& r)
0117 { return l.pointed_node() != r.pointed_node(); }
0118
0119 inline reference operator*() const
0120 { return *operator->(); }
0121
0122 inline pointer operator->() const
0123 { return this->operator_arrow(detail::bool_<stateful_value_traits>()); }
0124
0125 inline slist_iterator<ValueTraits, false> unconst() const
0126 { return slist_iterator<ValueTraits, false>(this->pointed_node(), this->get_value_traits()); }
0127
0128 private:
0129
0130 inline pointer operator_arrow(detail::false_) const
0131 { return ValueTraits::to_value_ptr(members_.nodeptr_); }
0132
0133 inline pointer operator_arrow(detail::true_) const
0134 { return this->get_value_traits()->to_value_ptr(members_.nodeptr_); }
0135
0136 iiterator_members<node_ptr, const_value_traits_ptr, stateful_value_traits> members_;
0137 };
0138
0139 }
0140 }
0141
0142 #include <boost/intrusive/detail/config_end.hpp>
0143
0144 #endif