File indexing completed on 2026-09-16 08:52:19
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014 #ifndef BOOST_MOVE_ITERATOR_HPP
0015 #define BOOST_MOVE_ITERATOR_HPP
0016
0017 #ifndef BOOST_CONFIG_HPP
0018 # include <boost/config.hpp>
0019 #endif
0020 0021 ">#
0022 #if defined(BOOST_HAS_PRAGMA_ONCE)
0023 # pragma once
0024 #endif
0025
0026 #include <boost/move/detail/config_begin.hpp>
0027 #include <boost/move/detail/workaround.hpp> //forceinline
0028 #include <boost/move/detail/iterator_traits.hpp>
0029 #include <boost/move/utility_core.hpp>
0030
0031 namespace boost {
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044 template <class It>
0045 class move_iterator
0046 {
0047 public:
0048 typedef It iterator_type;
0049 typedef typename boost::movelib::iterator_traits<iterator_type>::value_type value_type;
0050 #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) || defined(BOOST_MOVE_DOXYGEN_INVOKED)
0051 typedef value_type && reference;
0052 #else
0053 typedef typename ::boost::move_detail::if_
0054 < ::boost::has_move_emulation_enabled<value_type>
0055 , ::boost::rv<value_type>&
0056 , value_type & >::type reference;
0057 #endif
0058 typedef It pointer;
0059 typedef typename boost::movelib::iterator_traits<iterator_type>::difference_type difference_type;
0060 typedef typename boost::movelib::iterator_traits<iterator_type>::iterator_category iterator_category;
0061
0062 inline move_iterator()
0063 : m_it()
0064 {}
0065
0066 inline explicit move_iterator(const It &i)
0067 : m_it(i)
0068 {}
0069
0070 template <class U>
0071 inline move_iterator(const move_iterator<U>& u)
0072 : m_it(u.m_it)
0073 {}
0074
0075 inline reference operator*() const
0076 {
0077 #if defined(BOOST_NO_CXX11_RVALUE_REFERENCES) || defined(BOOST_MOVE_OLD_RVALUE_REF_BINDING_RULES)
0078 return *m_it;
0079 #else
0080 return ::boost::move(*m_it);
0081 #endif
0082 }
0083
0084 inline pointer operator->() const
0085 { return m_it; }
0086
0087 inline move_iterator& operator++()
0088 { ++m_it; return *this; }
0089
0090 inline move_iterator<iterator_type> operator++(int)
0091 { move_iterator<iterator_type> tmp(*this); ++(*this); return tmp; }
0092
0093 inline move_iterator& operator--()
0094 { --m_it; return *this; }
0095
0096 inline move_iterator<iterator_type> operator--(int)
0097 { move_iterator<iterator_type> tmp(*this); --(*this); return tmp; }
0098
0099 move_iterator<iterator_type> operator+ (difference_type n) const
0100 { return move_iterator<iterator_type>(m_it + n); }
0101
0102 inline move_iterator& operator+=(difference_type n)
0103 { m_it += n; return *this; }
0104
0105 inline move_iterator<iterator_type> operator- (difference_type n) const
0106 { return move_iterator<iterator_type>(m_it - n); }
0107
0108 inline move_iterator& operator-=(difference_type n)
0109 { m_it -= n; return *this; }
0110
0111 inline reference operator[](difference_type n) const
0112 {
0113 #if defined(BOOST_NO_CXX11_RVALUE_REFERENCES) || defined(BOOST_MOVE_OLD_RVALUE_REF_BINDING_RULES)
0114 return m_it[n];
0115 #else
0116 return ::boost::move(m_it[n]);
0117 #endif
0118 }
0119
0120 inline friend bool operator==(const move_iterator& x, const move_iterator& y)
0121 { return x.m_it == y.m_it; }
0122
0123 inline friend bool operator!=(const move_iterator& x, const move_iterator& y)
0124 { return x.m_it != y.m_it; }
0125
0126 inline friend bool operator< (const move_iterator& x, const move_iterator& y)
0127 { return x.m_it < y.m_it; }
0128
0129 inline friend bool operator<=(const move_iterator& x, const move_iterator& y)
0130 { return x.m_it <= y.m_it; }
0131
0132 inline friend bool operator> (const move_iterator& x, const move_iterator& y)
0133 { return x.m_it > y.m_it; }
0134
0135 inline friend bool operator>=(const move_iterator& x, const move_iterator& y)
0136 { return x.m_it >= y.m_it; }
0137
0138 inline friend difference_type operator-(const move_iterator& x, const move_iterator& y)
0139 { return x.m_it - y.m_it; }
0140
0141 inline friend move_iterator operator+(difference_type n, const move_iterator& x)
0142 { return move_iterator(x.m_it + n); }
0143
0144 private:
0145 It m_it;
0146 };
0147
0148
0149 namespace move_detail {
0150
0151 template <class I>
0152 struct is_move_iterator
0153 {
0154 static const bool value = false;
0155 };
0156
0157 template <class I>
0158 struct is_move_iterator< ::boost::move_iterator<I> >
0159 {
0160 static const bool value = true;
0161 };
0162
0163 }
0164
0165
0166
0167
0168
0169
0170
0171
0172
0173 template<class It>
0174 inline move_iterator<It> make_move_iterator(const It &it)
0175 { return move_iterator<It>(it); }
0176
0177
0178
0179
0180
0181
0182
0183
0184
0185
0186 template <typename C>
0187 class back_move_insert_iterator
0188 {
0189 C* container_m;
0190
0191 public:
0192 typedef C container_type;
0193 typedef typename C::value_type value_type;
0194 typedef typename C::reference reference;
0195 typedef typename C::pointer pointer;
0196 typedef typename C::difference_type difference_type;
0197 typedef std::output_iterator_tag iterator_category;
0198
0199 explicit back_move_insert_iterator(C& x) : container_m(&x) { }
0200
0201 back_move_insert_iterator& operator=(reference x)
0202 { container_m->push_back(boost::move(x)); return *this; }
0203
0204 back_move_insert_iterator& operator=(BOOST_RV_REF(value_type) x)
0205 { reference rx = x; return this->operator=(rx); }
0206
0207 back_move_insert_iterator& operator*() { return *this; }
0208 back_move_insert_iterator& operator++() { return *this; }
0209 back_move_insert_iterator& operator++(int) { return *this; }
0210 };
0211
0212
0213
0214 template <typename C>
0215 inline back_move_insert_iterator<C> back_move_inserter(C& x)
0216 {
0217 return back_move_insert_iterator<C>(x);
0218 }
0219
0220
0221
0222
0223
0224
0225
0226
0227
0228 template <typename C>
0229 class front_move_insert_iterator
0230 {
0231 C* container_m;
0232
0233 public:
0234 typedef C container_type;
0235 typedef typename C::value_type value_type;
0236 typedef typename C::reference reference;
0237 typedef typename C::pointer pointer;
0238 typedef typename C::difference_type difference_type;
0239 typedef std::output_iterator_tag iterator_category;
0240
0241 explicit front_move_insert_iterator(C& x) : container_m(&x) { }
0242
0243 front_move_insert_iterator& operator=(reference x)
0244 { container_m->push_front(boost::move(x)); return *this; }
0245
0246 front_move_insert_iterator& operator=(BOOST_RV_REF(value_type) x)
0247 { reference rx = x; return this->operator=(rx); }
0248
0249 front_move_insert_iterator& operator*() { return *this; }
0250 front_move_insert_iterator& operator++() { return *this; }
0251 front_move_insert_iterator& operator++(int) { return *this; }
0252 };
0253
0254
0255
0256 template <typename C>
0257 inline front_move_insert_iterator<C> front_move_inserter(C& x)
0258 {
0259 return front_move_insert_iterator<C>(x);
0260 }
0261
0262
0263
0264
0265
0266
0267 template <typename C>
0268 class move_insert_iterator
0269 {
0270 C* container_m;
0271 typename C::iterator pos_;
0272
0273 public:
0274 typedef C container_type;
0275 typedef typename C::value_type value_type;
0276 typedef typename C::reference reference;
0277 typedef typename C::pointer pointer;
0278 typedef typename C::difference_type difference_type;
0279 typedef std::output_iterator_tag iterator_category;
0280
0281 explicit move_insert_iterator(C& x, typename C::iterator pos)
0282 : container_m(&x), pos_(pos)
0283 {}
0284
0285 move_insert_iterator& operator=(reference x)
0286 {
0287 pos_ = container_m->insert(pos_, ::boost::move(x));
0288 ++pos_;
0289 return *this;
0290 }
0291
0292 move_insert_iterator& operator=(BOOST_RV_REF(value_type) x)
0293 { reference rx = x; return this->operator=(rx); }
0294
0295 move_insert_iterator& operator*() { return *this; }
0296 move_insert_iterator& operator++() { return *this; }
0297 move_insert_iterator& operator++(int) { return *this; }
0298 };
0299
0300
0301
0302 template <typename C>
0303 inline move_insert_iterator<C> move_inserter(C& x, typename C::iterator it)
0304 {
0305 return move_insert_iterator<C>(x, it);
0306 }
0307
0308 }
0309
0310 #include <boost/move/detail/config_end.hpp>
0311
0312 #endif