File indexing completed on 2025-01-18 09:30:12
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014 #ifndef BOOST_CONTAINER_DETAIL_ITERATORS_HPP
0015 #define BOOST_CONTAINER_DETAIL_ITERATORS_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/container/detail/config_begin.hpp>
0026 #include <boost/container/detail/workaround.hpp>
0027 #include <boost/container/allocator_traits.hpp>
0028 #include <boost/container/detail/type_traits.hpp>
0029 #include <boost/container/detail/value_init.hpp>
0030 #include <boost/static_assert.hpp>
0031 #include <boost/move/utility_core.hpp>
0032 #include <boost/intrusive/detail/reverse_iterator.hpp>
0033
0034 #if defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
0035 #include <boost/move/detail/fwd_macros.hpp>
0036 #else
0037 #include <boost/container/detail/variadic_templates_tools.hpp>
0038 #endif
0039 #include <boost/container/detail/iterator.hpp>
0040
0041 namespace boost {
0042 namespace container {
0043
0044 template <class T>
0045 class constant_iterator
0046 : public ::boost::container::iterator
0047 <std::random_access_iterator_tag, T, std::ptrdiff_t, const T*, const T &>
0048 {
0049 typedef constant_iterator<T> this_type;
0050
0051 public:
0052 BOOST_CONTAINER_FORCEINLINE explicit constant_iterator(const T &ref, std::size_t range_size)
0053 : m_ptr(&ref), m_num(range_size){}
0054
0055
0056 BOOST_CONTAINER_FORCEINLINE constant_iterator()
0057 : m_ptr(0), m_num(0){}
0058
0059 BOOST_CONTAINER_FORCEINLINE constant_iterator& operator++()
0060 { increment(); return *this; }
0061
0062 BOOST_CONTAINER_FORCEINLINE constant_iterator operator++(int)
0063 {
0064 constant_iterator result (*this);
0065 increment();
0066 return result;
0067 }
0068
0069 BOOST_CONTAINER_FORCEINLINE constant_iterator& operator--()
0070 { decrement(); return *this; }
0071
0072 BOOST_CONTAINER_FORCEINLINE constant_iterator operator--(int)
0073 {
0074 constant_iterator result (*this);
0075 decrement();
0076 return result;
0077 }
0078
0079 BOOST_CONTAINER_FORCEINLINE friend bool operator== (const constant_iterator& i, const constant_iterator& i2)
0080 { return i.equal(i2); }
0081
0082 BOOST_CONTAINER_FORCEINLINE friend bool operator!= (const constant_iterator& i, const constant_iterator& i2)
0083 { return !(i == i2); }
0084
0085 BOOST_CONTAINER_FORCEINLINE friend bool operator< (const constant_iterator& i, const constant_iterator& i2)
0086 { return i.less(i2); }
0087
0088 BOOST_CONTAINER_FORCEINLINE friend bool operator> (const constant_iterator& i, const constant_iterator& i2)
0089 { return i2 < i; }
0090
0091 BOOST_CONTAINER_FORCEINLINE friend bool operator<= (const constant_iterator& i, const constant_iterator& i2)
0092 { return !(i > i2); }
0093
0094 BOOST_CONTAINER_FORCEINLINE friend bool operator>= (const constant_iterator& i, const constant_iterator& i2)
0095 { return !(i < i2); }
0096
0097 BOOST_CONTAINER_FORCEINLINE friend std::ptrdiff_t operator- (const constant_iterator& i, const constant_iterator& i2)
0098 { return i2.distance_to(i); }
0099
0100
0101 BOOST_CONTAINER_FORCEINLINE constant_iterator& operator+=(std::ptrdiff_t off)
0102 { this->advance(off); return *this; }
0103
0104 BOOST_CONTAINER_FORCEINLINE constant_iterator operator+(std::ptrdiff_t off) const
0105 {
0106 constant_iterator other(*this);
0107 other.advance(off);
0108 return other;
0109 }
0110
0111 BOOST_CONTAINER_FORCEINLINE friend constant_iterator operator+(std::ptrdiff_t off, const constant_iterator& right)
0112 { return right + off; }
0113
0114 BOOST_CONTAINER_FORCEINLINE constant_iterator& operator-=(std::ptrdiff_t off)
0115 { this->advance(-off); return *this; }
0116
0117 BOOST_CONTAINER_FORCEINLINE constant_iterator operator-(std::ptrdiff_t off) const
0118 { return *this + (-off); }
0119
0120 BOOST_CONTAINER_FORCEINLINE const T& operator[] (std::ptrdiff_t ) const
0121 { return dereference(); }
0122
0123 BOOST_CONTAINER_FORCEINLINE const T& operator*() const
0124 { return dereference(); }
0125
0126 BOOST_CONTAINER_FORCEINLINE const T* operator->() const
0127 { return &(dereference()); }
0128
0129
0130 BOOST_CONTAINER_FORCEINLINE constant_iterator& operator+=(std::size_t off)
0131 { return *this += std::ptrdiff_t(off); }
0132
0133 BOOST_CONTAINER_FORCEINLINE constant_iterator operator+(std::size_t off) const
0134 { return *this + std::ptrdiff_t(off); }
0135
0136 BOOST_CONTAINER_FORCEINLINE friend constant_iterator operator+(std::size_t off, const constant_iterator& right)
0137 { return std::ptrdiff_t(off) + right; }
0138
0139 BOOST_CONTAINER_FORCEINLINE constant_iterator& operator-=(std::size_t off)
0140 { return *this -= std::ptrdiff_t(off); }
0141
0142 BOOST_CONTAINER_FORCEINLINE constant_iterator operator-(std::size_t off) const
0143 { return *this - std::ptrdiff_t(off); }
0144
0145 BOOST_CONTAINER_FORCEINLINE const T& operator[] (std::size_t off) const
0146 { return (*this)[std::ptrdiff_t(off)]; }
0147
0148 private:
0149 const T * m_ptr;
0150 std::size_t m_num;
0151
0152 BOOST_CONTAINER_FORCEINLINE void increment()
0153 { --m_num; }
0154
0155 BOOST_CONTAINER_FORCEINLINE void decrement()
0156 { ++m_num; }
0157
0158 BOOST_CONTAINER_FORCEINLINE bool equal(const this_type &other) const
0159 { return m_num == other.m_num; }
0160
0161 BOOST_CONTAINER_FORCEINLINE bool less(const this_type &other) const
0162 { return other.m_num < m_num; }
0163
0164 BOOST_CONTAINER_FORCEINLINE const T & dereference() const
0165 { return *m_ptr; }
0166
0167 BOOST_CONTAINER_FORCEINLINE void advance(std::ptrdiff_t n)
0168 { m_num = std::size_t(std::ptrdiff_t(m_num) - n); }
0169
0170 BOOST_CONTAINER_FORCEINLINE std::ptrdiff_t distance_to(const this_type &other)const
0171 { return std::ptrdiff_t(m_num - other.m_num); }
0172 };
0173
0174 template <class T>
0175 class value_init_construct_iterator
0176 : public ::boost::container::iterator
0177 <std::random_access_iterator_tag, T, std::ptrdiff_t, const T*, const T &>
0178 {
0179 typedef value_init_construct_iterator<T> this_type;
0180
0181 public:
0182 BOOST_CONTAINER_FORCEINLINE explicit value_init_construct_iterator(std::size_t range_size)
0183 : m_num(range_size){}
0184
0185
0186 BOOST_CONTAINER_FORCEINLINE value_init_construct_iterator()
0187 : m_num(0){}
0188
0189 BOOST_CONTAINER_FORCEINLINE value_init_construct_iterator& operator++()
0190 { increment(); return *this; }
0191
0192 BOOST_CONTAINER_FORCEINLINE value_init_construct_iterator operator++(int)
0193 {
0194 value_init_construct_iterator result (*this);
0195 increment();
0196 return result;
0197 }
0198
0199 BOOST_CONTAINER_FORCEINLINE value_init_construct_iterator& operator--()
0200 { decrement(); return *this; }
0201
0202 BOOST_CONTAINER_FORCEINLINE value_init_construct_iterator operator--(int)
0203 {
0204 value_init_construct_iterator result (*this);
0205 decrement();
0206 return result;
0207 }
0208
0209 BOOST_CONTAINER_FORCEINLINE friend bool operator== (const value_init_construct_iterator& i, const value_init_construct_iterator& i2)
0210 { return i.equal(i2); }
0211
0212 BOOST_CONTAINER_FORCEINLINE friend bool operator!= (const value_init_construct_iterator& i, const value_init_construct_iterator& i2)
0213 { return !(i == i2); }
0214
0215 BOOST_CONTAINER_FORCEINLINE friend bool operator< (const value_init_construct_iterator& i, const value_init_construct_iterator& i2)
0216 { return i.less(i2); }
0217
0218 BOOST_CONTAINER_FORCEINLINE friend bool operator> (const value_init_construct_iterator& i, const value_init_construct_iterator& i2)
0219 { return i2 < i; }
0220
0221 BOOST_CONTAINER_FORCEINLINE friend bool operator<= (const value_init_construct_iterator& i, const value_init_construct_iterator& i2)
0222 { return !(i > i2); }
0223
0224 BOOST_CONTAINER_FORCEINLINE friend bool operator>= (const value_init_construct_iterator& i, const value_init_construct_iterator& i2)
0225 { return !(i < i2); }
0226
0227 BOOST_CONTAINER_FORCEINLINE friend std::ptrdiff_t operator- (const value_init_construct_iterator& i, const value_init_construct_iterator& i2)
0228 { return i2.distance_to(i); }
0229
0230
0231 BOOST_CONTAINER_FORCEINLINE value_init_construct_iterator& operator+=(std::ptrdiff_t off)
0232 { this->advance(off); return *this; }
0233
0234 BOOST_CONTAINER_FORCEINLINE value_init_construct_iterator operator+(std::ptrdiff_t off) const
0235 {
0236 value_init_construct_iterator other(*this);
0237 other.advance(off);
0238 return other;
0239 }
0240
0241 BOOST_CONTAINER_FORCEINLINE friend value_init_construct_iterator operator+(std::ptrdiff_t off, const value_init_construct_iterator& right)
0242 { return right + off; }
0243
0244 BOOST_CONTAINER_FORCEINLINE value_init_construct_iterator& operator-=(std::ptrdiff_t off)
0245 { this->advance(-off); return *this; }
0246
0247 BOOST_CONTAINER_FORCEINLINE value_init_construct_iterator operator-(std::ptrdiff_t off) const
0248 { return *this + (-off); }
0249
0250
0251
0252
0253
0254
0255
0256
0257 private:
0258 std::size_t m_num;
0259
0260 BOOST_CONTAINER_FORCEINLINE void increment()
0261 { --m_num; }
0262
0263 BOOST_CONTAINER_FORCEINLINE void decrement()
0264 { ++m_num; }
0265
0266 BOOST_CONTAINER_FORCEINLINE bool equal(const this_type &other) const
0267 { return m_num == other.m_num; }
0268
0269 BOOST_CONTAINER_FORCEINLINE bool less(const this_type &other) const
0270 { return other.m_num < m_num; }
0271
0272 BOOST_CONTAINER_FORCEINLINE const T & dereference() const
0273 {
0274 static T dummy;
0275 return dummy;
0276 }
0277
0278 BOOST_CONTAINER_FORCEINLINE void advance(std::ptrdiff_t n)
0279 { m_num = std::size_t(std::ptrdiff_t(m_num) - n); }
0280
0281 BOOST_CONTAINER_FORCEINLINE std::ptrdiff_t distance_to(const this_type &other)const
0282 { return std::ptrdiff_t(m_num - other.m_num); }
0283 };
0284
0285 template <class T>
0286 class default_init_construct_iterator
0287 : public ::boost::container::iterator
0288 <std::random_access_iterator_tag, T, std::ptrdiff_t, const T*, const T &>
0289 {
0290 typedef default_init_construct_iterator<T> this_type;
0291
0292 public:
0293 BOOST_CONTAINER_FORCEINLINE explicit default_init_construct_iterator(std::size_t range_size)
0294 : m_num(range_size){}
0295
0296
0297 BOOST_CONTAINER_FORCEINLINE default_init_construct_iterator()
0298 : m_num(0){}
0299
0300 BOOST_CONTAINER_FORCEINLINE default_init_construct_iterator& operator++()
0301 { increment(); return *this; }
0302
0303 BOOST_CONTAINER_FORCEINLINE default_init_construct_iterator operator++(int)
0304 {
0305 default_init_construct_iterator result (*this);
0306 increment();
0307 return result;
0308 }
0309
0310 BOOST_CONTAINER_FORCEINLINE default_init_construct_iterator& operator--()
0311 { decrement(); return *this; }
0312
0313 BOOST_CONTAINER_FORCEINLINE default_init_construct_iterator operator--(int)
0314 {
0315 default_init_construct_iterator result (*this);
0316 decrement();
0317 return result;
0318 }
0319
0320 BOOST_CONTAINER_FORCEINLINE friend bool operator== (const default_init_construct_iterator& i, const default_init_construct_iterator& i2)
0321 { return i.equal(i2); }
0322
0323 BOOST_CONTAINER_FORCEINLINE friend bool operator!= (const default_init_construct_iterator& i, const default_init_construct_iterator& i2)
0324 { return !(i == i2); }
0325
0326 BOOST_CONTAINER_FORCEINLINE friend bool operator< (const default_init_construct_iterator& i, const default_init_construct_iterator& i2)
0327 { return i.less(i2); }
0328
0329 BOOST_CONTAINER_FORCEINLINE friend bool operator> (const default_init_construct_iterator& i, const default_init_construct_iterator& i2)
0330 { return i2 < i; }
0331
0332 BOOST_CONTAINER_FORCEINLINE friend bool operator<= (const default_init_construct_iterator& i, const default_init_construct_iterator& i2)
0333 { return !(i > i2); }
0334
0335 BOOST_CONTAINER_FORCEINLINE friend bool operator>= (const default_init_construct_iterator& i, const default_init_construct_iterator& i2)
0336 { return !(i < i2); }
0337
0338 BOOST_CONTAINER_FORCEINLINE friend std::ptrdiff_t operator- (const default_init_construct_iterator& i, const default_init_construct_iterator& i2)
0339 { return i2.distance_to(i); }
0340
0341
0342 BOOST_CONTAINER_FORCEINLINE default_init_construct_iterator& operator+=(std::ptrdiff_t off)
0343 { this->advance(off); return *this; }
0344
0345 BOOST_CONTAINER_FORCEINLINE default_init_construct_iterator operator+(std::ptrdiff_t off) const
0346 {
0347 default_init_construct_iterator other(*this);
0348 other.advance(off);
0349 return other;
0350 }
0351
0352 BOOST_CONTAINER_FORCEINLINE friend default_init_construct_iterator operator+(std::ptrdiff_t off, const default_init_construct_iterator& right)
0353 { return right + off; }
0354
0355 BOOST_CONTAINER_FORCEINLINE default_init_construct_iterator& operator-=(std::ptrdiff_t off)
0356 { this->advance(-off); return *this; }
0357
0358 BOOST_CONTAINER_FORCEINLINE default_init_construct_iterator operator-(std::ptrdiff_t off) const
0359 { return *this + (-off); }
0360
0361
0362
0363
0364
0365
0366
0367
0368 private:
0369 std::size_t m_num;
0370
0371 BOOST_CONTAINER_FORCEINLINE void increment()
0372 { --m_num; }
0373
0374 BOOST_CONTAINER_FORCEINLINE void decrement()
0375 { ++m_num; }
0376
0377 BOOST_CONTAINER_FORCEINLINE bool equal(const this_type &other) const
0378 { return m_num == other.m_num; }
0379
0380 BOOST_CONTAINER_FORCEINLINE bool less(const this_type &other) const
0381 { return other.m_num < m_num; }
0382
0383 BOOST_CONTAINER_FORCEINLINE const T & dereference() const
0384 {
0385 static T dummy;
0386 return dummy;
0387 }
0388
0389 BOOST_CONTAINER_FORCEINLINE void advance(std::ptrdiff_t n)
0390 { m_num = std::size_t(std::ptrdiff_t(m_num) - n); }
0391
0392 BOOST_CONTAINER_FORCEINLINE std::ptrdiff_t distance_to(const this_type &other) const
0393 { return std::ptrdiff_t(m_num - other.m_num); }
0394 };
0395
0396
0397 template <class T>
0398 class repeat_iterator
0399 : public ::boost::container::iterator
0400 <std::random_access_iterator_tag, T, std::ptrdiff_t, T*, T&>
0401 {
0402 typedef repeat_iterator<T> this_type;
0403 public:
0404 BOOST_CONTAINER_FORCEINLINE explicit repeat_iterator(T &ref, std::size_t range_size)
0405 : m_ptr(&ref), m_num(range_size){}
0406
0407
0408 BOOST_CONTAINER_FORCEINLINE repeat_iterator()
0409 : m_ptr(0), m_num(0){}
0410
0411 BOOST_CONTAINER_FORCEINLINE this_type& operator++()
0412 { increment(); return *this; }
0413
0414 BOOST_CONTAINER_FORCEINLINE this_type operator++(int)
0415 {
0416 this_type result (*this);
0417 increment();
0418 return result;
0419 }
0420
0421 BOOST_CONTAINER_FORCEINLINE this_type& operator--()
0422 { increment(); return *this; }
0423
0424 BOOST_CONTAINER_FORCEINLINE this_type operator--(int)
0425 {
0426 this_type result (*this);
0427 increment();
0428 return result;
0429 }
0430
0431 BOOST_CONTAINER_FORCEINLINE friend bool operator== (const this_type& i, const this_type& i2)
0432 { return i.equal(i2); }
0433
0434 BOOST_CONTAINER_FORCEINLINE friend bool operator!= (const this_type& i, const this_type& i2)
0435 { return !(i == i2); }
0436
0437 BOOST_CONTAINER_FORCEINLINE friend bool operator< (const this_type& i, const this_type& i2)
0438 { return i.less(i2); }
0439
0440 BOOST_CONTAINER_FORCEINLINE friend bool operator> (const this_type& i, const this_type& i2)
0441 { return i2 < i; }
0442
0443 BOOST_CONTAINER_FORCEINLINE friend bool operator<= (const this_type& i, const this_type& i2)
0444 { return !(i > i2); }
0445
0446 BOOST_CONTAINER_FORCEINLINE friend bool operator>= (const this_type& i, const this_type& i2)
0447 { return !(i < i2); }
0448
0449 BOOST_CONTAINER_FORCEINLINE friend std::ptrdiff_t operator- (const this_type& i, const this_type& i2)
0450 { return i2.distance_to(i); }
0451
0452
0453 BOOST_CONTAINER_FORCEINLINE this_type& operator+=(std::ptrdiff_t off)
0454 { this->advance(off); return *this; }
0455
0456 BOOST_CONTAINER_FORCEINLINE this_type operator+(std::ptrdiff_t off) const
0457 {
0458 this_type other(*this);
0459 other.advance(off);
0460 return other;
0461 }
0462
0463 BOOST_CONTAINER_FORCEINLINE friend this_type operator+(std::ptrdiff_t off, const this_type& right)
0464 { return right + off; }
0465
0466 BOOST_CONTAINER_FORCEINLINE this_type& operator-=(std::ptrdiff_t off)
0467 { this->advance(-off); return *this; }
0468
0469 BOOST_CONTAINER_FORCEINLINE this_type operator-(std::ptrdiff_t off) const
0470 { return *this + (-off); }
0471
0472 BOOST_CONTAINER_FORCEINLINE T& operator*() const
0473 { return dereference(); }
0474
0475 BOOST_CONTAINER_FORCEINLINE T& operator[] (std::ptrdiff_t ) const
0476 { return dereference(); }
0477
0478 BOOST_CONTAINER_FORCEINLINE T *operator->() const
0479 { return &(dereference()); }
0480
0481 private:
0482 T * m_ptr;
0483 std::size_t m_num;
0484
0485 BOOST_CONTAINER_FORCEINLINE void increment()
0486 { --m_num; }
0487
0488 BOOST_CONTAINER_FORCEINLINE void decrement()
0489 { ++m_num; }
0490
0491 BOOST_CONTAINER_FORCEINLINE bool equal(const this_type &other) const
0492 { return m_num == other.m_num; }
0493
0494 BOOST_CONTAINER_FORCEINLINE bool less(const this_type &other) const
0495 { return other.m_num < m_num; }
0496
0497 BOOST_CONTAINER_FORCEINLINE T & dereference() const
0498 { return *m_ptr; }
0499
0500 BOOST_CONTAINER_FORCEINLINE void advance(std::ptrdiff_t n)
0501 { m_num = std::size_t(std::ptrdiff_t(m_num - n)); }
0502
0503 BOOST_CONTAINER_FORCEINLINE std::ptrdiff_t distance_to(const this_type &other)const
0504 { return std::ptrdiff_t(m_num - other.m_num); }
0505 };
0506
0507 template <class T, class EmplaceFunctor>
0508 class emplace_iterator
0509 : public ::boost::container::iterator
0510 <std::random_access_iterator_tag, T, std::ptrdiff_t, const T*, const T &>
0511 {
0512 typedef emplace_iterator this_type;
0513
0514 public:
0515 typedef std::ptrdiff_t difference_type;
0516 BOOST_CONTAINER_FORCEINLINE explicit emplace_iterator(EmplaceFunctor&e)
0517 : m_num(1), m_pe(&e){}
0518
0519 BOOST_CONTAINER_FORCEINLINE emplace_iterator()
0520 : m_num(0), m_pe(0){}
0521
0522 BOOST_CONTAINER_FORCEINLINE this_type& operator++()
0523 { increment(); return *this; }
0524
0525 BOOST_CONTAINER_FORCEINLINE this_type operator++(int)
0526 {
0527 this_type result (*this);
0528 increment();
0529 return result;
0530 }
0531
0532 BOOST_CONTAINER_FORCEINLINE this_type& operator--()
0533 { decrement(); return *this; }
0534
0535 BOOST_CONTAINER_FORCEINLINE this_type operator--(int)
0536 {
0537 this_type result (*this);
0538 decrement();
0539 return result;
0540 }
0541
0542 BOOST_CONTAINER_FORCEINLINE friend bool operator== (const this_type& i, const this_type& i2)
0543 { return i.equal(i2); }
0544
0545 BOOST_CONTAINER_FORCEINLINE friend bool operator!= (const this_type& i, const this_type& i2)
0546 { return !(i == i2); }
0547
0548 BOOST_CONTAINER_FORCEINLINE friend bool operator< (const this_type& i, const this_type& i2)
0549 { return i.less(i2); }
0550
0551 BOOST_CONTAINER_FORCEINLINE friend bool operator> (const this_type& i, const this_type& i2)
0552 { return i2 < i; }
0553
0554 BOOST_CONTAINER_FORCEINLINE friend bool operator<= (const this_type& i, const this_type& i2)
0555 { return !(i > i2); }
0556
0557 BOOST_CONTAINER_FORCEINLINE friend bool operator>= (const this_type& i, const this_type& i2)
0558 { return !(i < i2); }
0559
0560 BOOST_CONTAINER_FORCEINLINE friend difference_type operator- (const this_type& i, const this_type& i2)
0561 { return i2.distance_to(i); }
0562
0563
0564 BOOST_CONTAINER_FORCEINLINE this_type& operator+=(difference_type off)
0565 { this->advance(off); return *this; }
0566
0567 BOOST_CONTAINER_FORCEINLINE this_type operator+(difference_type off) const
0568 {
0569 this_type other(*this);
0570 other.advance(off);
0571 return other;
0572 }
0573
0574 BOOST_CONTAINER_FORCEINLINE friend this_type operator+(difference_type off, const this_type& right)
0575 { return right + off; }
0576
0577 BOOST_CONTAINER_FORCEINLINE this_type& operator-=(difference_type off)
0578 { this->advance(-off); return *this; }
0579
0580 BOOST_CONTAINER_FORCEINLINE this_type operator-(difference_type off) const
0581 { return *this + (-off); }
0582
0583 private:
0584
0585
0586
0587 const T& operator*() const;
0588 const T& operator[](difference_type) const;
0589 const T* operator->() const;
0590
0591 public:
0592 template<class Allocator>
0593 BOOST_CONTAINER_FORCEINLINE void construct_in_place(Allocator &a, T* ptr)
0594 { (*m_pe)(a, ptr); }
0595
0596 template<class DestIt>
0597 BOOST_CONTAINER_FORCEINLINE void assign_in_place(DestIt dest)
0598 { (*m_pe)(dest); }
0599
0600 private:
0601 std::size_t m_num;
0602 EmplaceFunctor * m_pe;
0603
0604 BOOST_CONTAINER_FORCEINLINE void increment()
0605 { --m_num; }
0606
0607 BOOST_CONTAINER_FORCEINLINE void decrement()
0608 { ++m_num; }
0609
0610 BOOST_CONTAINER_FORCEINLINE bool equal(const this_type &other) const
0611 { return m_num == other.m_num; }
0612
0613 BOOST_CONTAINER_FORCEINLINE bool less(const this_type &other) const
0614 { return other.m_num < m_num; }
0615
0616 BOOST_CONTAINER_FORCEINLINE const T & dereference() const
0617 {
0618 static T dummy;
0619 return dummy;
0620 }
0621
0622 BOOST_CONTAINER_FORCEINLINE void advance(difference_type n)
0623 { m_num -= n; }
0624
0625 BOOST_CONTAINER_FORCEINLINE difference_type distance_to(const this_type &other)const
0626 { return difference_type(m_num - other.m_num); }
0627 };
0628
0629 #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
0630
0631 template<class ...Args>
0632 struct emplace_functor
0633 {
0634 typedef typename dtl::build_number_seq<sizeof...(Args)>::type index_tuple_t;
0635
0636 BOOST_CONTAINER_FORCEINLINE emplace_functor(BOOST_FWD_REF(Args)... args)
0637 : args_(args...)
0638 {}
0639
0640 template<class Allocator, class T>
0641 BOOST_CONTAINER_FORCEINLINE void operator()(Allocator &a, T *ptr)
0642 { emplace_functor::inplace_impl(a, ptr, index_tuple_t()); }
0643
0644 template<class DestIt>
0645 BOOST_CONTAINER_FORCEINLINE void operator()(DestIt dest)
0646 { emplace_functor::inplace_impl(dest, index_tuple_t()); }
0647
0648 private:
0649 template<class Allocator, class T, std::size_t ...IdxPack>
0650 BOOST_CONTAINER_FORCEINLINE void inplace_impl(Allocator &a, T* ptr, const dtl::index_tuple<IdxPack...>&)
0651 {
0652 allocator_traits<Allocator>::construct
0653 (a, ptr, ::boost::forward<Args>(dtl::get<IdxPack>(args_))...);
0654 }
0655
0656 template<class DestIt, std::size_t ...IdxPack>
0657 BOOST_CONTAINER_FORCEINLINE void inplace_impl(DestIt dest, const dtl::index_tuple<IdxPack...>&)
0658 {
0659 typedef typename boost::container::iterator_traits<DestIt>::value_type value_type;
0660 value_type && tmp= value_type(::boost::forward<Args>(dtl::get<IdxPack>(args_))...);
0661 *dest = ::boost::move(tmp);
0662 }
0663
0664 dtl::tuple<Args&...> args_;
0665 };
0666
0667 template<class ...Args>
0668 struct emplace_functor_type
0669 {
0670 typedef emplace_functor<Args...> type;
0671 };
0672
0673 #else
0674
0675
0676 template <BOOST_MOVE_CLASSDFLT9, class Dummy = void>
0677 struct emplace_functor_type;
0678
0679 #define BOOST_MOVE_ITERATOR_EMPLACE_FUNCTOR_CODE(N) \
0680 BOOST_MOVE_TMPL_LT##N BOOST_MOVE_CLASS##N BOOST_MOVE_GT##N \
0681 struct emplace_functor##N\
0682 {\
0683 BOOST_CONTAINER_FORCEINLINE explicit emplace_functor##N( BOOST_MOVE_UREF##N )\
0684 BOOST_MOVE_COLON##N BOOST_MOVE_FWD_INIT##N{}\
0685 \
0686 template<class Allocator, class T>\
0687 BOOST_CONTAINER_FORCEINLINE void operator()(Allocator &a, T *ptr)\
0688 { allocator_traits<Allocator>::construct(a, ptr BOOST_MOVE_I##N BOOST_MOVE_MFWD##N); }\
0689 \
0690 template<class DestIt>\
0691 BOOST_CONTAINER_FORCEINLINE void operator()(DestIt dest)\
0692 {\
0693 typedef typename boost::container::iterator_traits<DestIt>::value_type value_type;\
0694 BOOST_MOVE_IF(N, value_type tmp(BOOST_MOVE_MFWD##N), dtl::value_init<value_type> tmp) ;\
0695 *dest = ::boost::move(const_cast<value_type &>(BOOST_MOVE_IF(N, tmp, tmp.get())));\
0696 }\
0697 \
0698 BOOST_MOVE_MREF##N\
0699 };\
0700 \
0701 template <BOOST_MOVE_CLASS##N>\
0702 struct emplace_functor_type<BOOST_MOVE_TARG##N>\
0703 {\
0704 typedef emplace_functor##N BOOST_MOVE_LT##N BOOST_MOVE_TARG##N BOOST_MOVE_GT##N type;\
0705 };\
0706
0707
0708 BOOST_MOVE_ITERATE_0TO9(BOOST_MOVE_ITERATOR_EMPLACE_FUNCTOR_CODE)
0709
0710 #undef BOOST_MOVE_ITERATOR_EMPLACE_FUNCTOR_CODE
0711
0712 #endif
0713
0714 namespace dtl {
0715
0716 template<class T>
0717 struct has_iterator_category
0718 {
0719 struct two { char _[2]; };
0720
0721 template <typename X>
0722 static char test(int, typename X::iterator_category*);
0723
0724 template <typename X>
0725 static two test(int, ...);
0726
0727 static const bool value = (1 == sizeof(test<T>(0, 0)));
0728 };
0729
0730
0731 template<class T, bool = has_iterator_category<T>::value >
0732 struct is_input_iterator
0733 {
0734 static const bool value = is_same<typename T::iterator_category, std::input_iterator_tag>::value;
0735 };
0736
0737 template<class T>
0738 struct is_input_iterator<T, false>
0739 {
0740 static const bool value = false;
0741 };
0742
0743 template<class T>
0744 struct is_not_input_iterator
0745 {
0746 static const bool value = !is_input_iterator<T>::value;
0747 };
0748
0749 template<class T, bool = has_iterator_category<T>::value >
0750 struct is_forward_iterator
0751 {
0752 static const bool value = is_same<typename T::iterator_category, std::forward_iterator_tag>::value;
0753 };
0754
0755 template<class T>
0756 struct is_forward_iterator<T, false>
0757 {
0758 static const bool value = false;
0759 };
0760
0761 template<class T, bool = has_iterator_category<T>::value >
0762 struct is_bidirectional_iterator
0763 {
0764 static const bool value = is_same<typename T::iterator_category, std::bidirectional_iterator_tag>::value;
0765 };
0766
0767 template<class T>
0768 struct is_bidirectional_iterator<T, false>
0769 {
0770 static const bool value = false;
0771 };
0772
0773 template<class IINodeType>
0774 struct iiterator_node_value_type {
0775 typedef typename IINodeType::value_type type;
0776 };
0777
0778 template<class IIterator>
0779 struct iiterator_types
0780 {
0781 typedef typename IIterator::value_type it_value_type;
0782 typedef typename iiterator_node_value_type<it_value_type>::type value_type;
0783 typedef typename boost::container::iterator_traits<IIterator>::pointer it_pointer;
0784 typedef typename boost::container::iterator_traits<IIterator>::difference_type difference_type;
0785 typedef typename ::boost::intrusive::pointer_traits<it_pointer>::
0786 template rebind_pointer<value_type>::type pointer;
0787 typedef typename ::boost::intrusive::pointer_traits<it_pointer>::
0788 template rebind_pointer<const value_type>::type const_pointer;
0789 typedef typename ::boost::intrusive::
0790 pointer_traits<pointer>::reference reference;
0791 typedef typename ::boost::intrusive::
0792 pointer_traits<const_pointer>::reference const_reference;
0793 typedef typename IIterator::iterator_category iterator_category;
0794 };
0795
0796 template<class IIterator, bool IsConst>
0797 struct iterator_types
0798 {
0799 typedef typename ::boost::container::iterator
0800 < typename iiterator_types<IIterator>::iterator_category
0801 , typename iiterator_types<IIterator>::value_type
0802 , typename iiterator_types<IIterator>::difference_type
0803 , typename iiterator_types<IIterator>::const_pointer
0804 , typename iiterator_types<IIterator>::const_reference> type;
0805 };
0806
0807 template<class IIterator>
0808 struct iterator_types<IIterator, false>
0809 {
0810 typedef typename ::boost::container::iterator
0811 < typename iiterator_types<IIterator>::iterator_category
0812 , typename iiterator_types<IIterator>::value_type
0813 , typename iiterator_types<IIterator>::difference_type
0814 , typename iiterator_types<IIterator>::pointer
0815 , typename iiterator_types<IIterator>::reference> type;
0816 };
0817
0818 template<class IIterator, bool IsConst>
0819 class iterator_from_iiterator
0820 {
0821 typedef typename iterator_types<IIterator, IsConst>::type types_t;
0822 class nat
0823 {
0824 public:
0825 IIterator get() const
0826 { return IIterator(); }
0827 };
0828 typedef typename dtl::if_c< IsConst
0829 , iterator_from_iiterator<IIterator, false>
0830 , nat>::type nonconst_iterator;
0831
0832 public:
0833 typedef typename types_t::pointer pointer;
0834 typedef typename types_t::reference reference;
0835 typedef typename types_t::difference_type difference_type;
0836 typedef typename types_t::iterator_category iterator_category;
0837 typedef typename types_t::value_type value_type;
0838
0839 BOOST_CONTAINER_FORCEINLINE iterator_from_iiterator()
0840 : m_iit()
0841 {}
0842
0843 BOOST_CONTAINER_FORCEINLINE explicit iterator_from_iiterator(IIterator iit) BOOST_NOEXCEPT_OR_NOTHROW
0844 : m_iit(iit)
0845 {}
0846
0847 BOOST_CONTAINER_FORCEINLINE iterator_from_iiterator(const iterator_from_iiterator& other) BOOST_NOEXCEPT_OR_NOTHROW
0848 : m_iit(other.get())
0849 {}
0850
0851 BOOST_CONTAINER_FORCEINLINE iterator_from_iiterator(const nonconst_iterator& other) BOOST_NOEXCEPT_OR_NOTHROW
0852 : m_iit(other.get())
0853 {}
0854
0855 BOOST_CONTAINER_FORCEINLINE iterator_from_iiterator& operator=(const iterator_from_iiterator& other) BOOST_NOEXCEPT_OR_NOTHROW
0856 { m_iit = other.get(); return *this; }
0857
0858 BOOST_CONTAINER_FORCEINLINE iterator_from_iiterator& operator++() BOOST_NOEXCEPT_OR_NOTHROW
0859 { ++this->m_iit; return *this; }
0860
0861 BOOST_CONTAINER_FORCEINLINE iterator_from_iiterator operator++(int) BOOST_NOEXCEPT_OR_NOTHROW
0862 {
0863 iterator_from_iiterator result (*this);
0864 ++this->m_iit;
0865 return result;
0866 }
0867
0868 BOOST_CONTAINER_FORCEINLINE iterator_from_iiterator& operator--() BOOST_NOEXCEPT_OR_NOTHROW
0869 {
0870
0871 BOOST_STATIC_ASSERT((is_bidirectional_iterator<iterator_from_iiterator>::value));
0872 --this->m_iit; return *this;
0873 }
0874
0875 BOOST_CONTAINER_FORCEINLINE iterator_from_iiterator operator--(int) BOOST_NOEXCEPT_OR_NOTHROW
0876 {
0877 iterator_from_iiterator result (*this);
0878 --this->m_iit;
0879 return result;
0880 }
0881
0882 BOOST_CONTAINER_FORCEINLINE friend bool operator== (const iterator_from_iiterator& l, const iterator_from_iiterator& r) BOOST_NOEXCEPT_OR_NOTHROW
0883 { return l.m_iit == r.m_iit; }
0884
0885 BOOST_CONTAINER_FORCEINLINE friend bool operator!= (const iterator_from_iiterator& l, const iterator_from_iiterator& r) BOOST_NOEXCEPT_OR_NOTHROW
0886 { return l.m_iit != r.m_iit; }
0887
0888 BOOST_CONTAINER_FORCEINLINE reference operator*() const BOOST_NOEXCEPT_OR_NOTHROW
0889 { return this->m_iit->get_data(); }
0890
0891 BOOST_CONTAINER_FORCEINLINE pointer operator->() const BOOST_NOEXCEPT_OR_NOTHROW
0892 { return ::boost::intrusive::pointer_traits<pointer>::pointer_to(this->operator*()); }
0893
0894 BOOST_CONTAINER_FORCEINLINE const IIterator &get() const BOOST_NOEXCEPT_OR_NOTHROW
0895 { return this->m_iit; }
0896
0897 private:
0898 IIterator m_iit;
0899 };
0900
0901 }
0902
0903 using ::boost::intrusive::reverse_iterator;
0904
0905 }
0906 }
0907
0908 #include <boost/container/detail/config_end.hpp>
0909
0910 #endif