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