Warning, file /include/boost/foreach.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
0015
0016
0017
0018
0019
0020 #ifndef BOOST_FOREACH
0021
0022
0023 #if defined(_MSC_VER)
0024 # pragma once
0025 #endif
0026
0027 #include <cstddef>
0028 #include <utility> // for std::pair
0029
0030 #include <boost/config.hpp>
0031 #include <boost/detail/workaround.hpp>
0032
0033
0034 #if defined(BOOST_NO_NULLPTR)
0035 #define BOOST_FOREACH_NULL 0
0036 #else
0037 #define BOOST_FOREACH_NULL nullptr
0038 #endif
0039
0040
0041 #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) \
0042 || defined(BOOST_MSVC) && !defined(_PREFAST_) \
0043 || (BOOST_WORKAROUND(__GNUC__, == 4) && (__GNUC_MINOR__ <= 5) && !defined(BOOST_INTEL) && \
0044 !defined(BOOST_CLANG)) \
0045 || (BOOST_WORKAROUND(__GNUC__, == 3) && (__GNUC_MINOR__ >= 4) && !defined(BOOST_INTEL) && \
0046 !defined(BOOST_CLANG))
0047 # define BOOST_FOREACH_COMPILE_TIME_CONST_RVALUE_DETECTION
0048 #else
0049
0050
0051
0052 # if BOOST_WORKAROUND(BOOST_BORLANDC, < 0x593) \
0053 || (BOOST_WORKAROUND(BOOST_INTEL_CXX_VERSION, <= 700) && defined(_MSC_VER)) \
0054 || BOOST_WORKAROUND(__SUNPRO_CC, < 0x5100) \
0055 || BOOST_WORKAROUND(__DECCXX_VER, <= 60590042)
0056 # define BOOST_FOREACH_NO_RVALUE_DETECTION
0057 # endif
0058
0059
0060 # if defined(BOOST_FOREACH_NO_RVALUE_DETECTION) \
0061 || defined(BOOST_NO_SFINAE) \
0062 || BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1400)) \
0063 || BOOST_WORKAROUND(BOOST_INTEL_WIN, BOOST_TESTED_AT(1400)) \
0064 || (BOOST_WORKAROUND(__GNUC__, == 3) && (__GNUC_MINOR__ <= 3) && defined(__APPLE_CC__)) \
0065 || BOOST_WORKAROUND(__IBMCPP__, BOOST_TESTED_AT(600)) \
0066 || BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3206)) \
0067 || BOOST_WORKAROUND(__SUNPRO_CC, >= 0x5100) \
0068 || BOOST_WORKAROUND(BOOST_BORLANDC, BOOST_TESTED_AT(0x590))
0069 # define BOOST_FOREACH_NO_CONST_RVALUE_DETECTION
0070 # else
0071 # define BOOST_FOREACH_RUN_TIME_CONST_RVALUE_DETECTION
0072 # endif
0073 #endif
0074
0075 #include <boost/mpl/if.hpp>
0076 #include <boost/mpl/assert.hpp>
0077 #include <boost/mpl/logical.hpp>
0078 #include <boost/mpl/eval_if.hpp>
0079 #include <boost/noncopyable.hpp>
0080 #include <boost/range/end.hpp>
0081 #include <boost/range/begin.hpp>
0082 #include <boost/range/rend.hpp>
0083 #include <boost/range/rbegin.hpp>
0084 #include <boost/range/iterator.hpp>
0085 #include <boost/range/reverse_iterator.hpp>
0086 #include <boost/type_traits/is_array.hpp>
0087 #include <boost/type_traits/is_const.hpp>
0088 #include <boost/type_traits/is_abstract.hpp>
0089 #include <boost/type_traits/is_base_and_derived.hpp>
0090 #include <boost/type_traits/is_rvalue_reference.hpp>
0091 #include <boost/type_traits/is_convertible.hpp>
0092 #include <boost/iterator/iterator_traits.hpp>
0093 #include <boost/utility/addressof.hpp>
0094 #include <boost/foreach_fwd.hpp>
0095
0096 #ifdef BOOST_FOREACH_RUN_TIME_CONST_RVALUE_DETECTION
0097 # include <new>
0098 # include <boost/aligned_storage.hpp>
0099 # include <boost/utility/enable_if.hpp>
0100 # include <boost/type_traits/remove_const.hpp>
0101 #endif
0102
0103 namespace boost
0104 {
0105
0106
0107 template<typename T>
0108 class iterator_range;
0109
0110
0111 template<typename T>
0112 class sub_range;
0113
0114 namespace foreach
0115 {
0116
0117
0118
0119 template<typename T>
0120 inline std::pair<T, T> in_range(T begin, T end)
0121 {
0122 return std::make_pair(begin, end);
0123 }
0124
0125
0126
0127
0128
0129 template<typename T>
0130 struct is_lightweight_proxy
0131 : boost::mpl::false_
0132 {
0133 };
0134
0135
0136
0137
0138
0139 template<typename T>
0140 struct is_noncopyable
0141 #if !defined(BOOST_BROKEN_IS_BASE_AND_DERIVED) && !defined(BOOST_NO_IS_ABSTRACT)
0142 : boost::mpl::or_<
0143 boost::is_abstract<T>
0144 , boost::is_base_and_derived<boost::noncopyable, T>
0145 >
0146 #elif !defined(BOOST_BROKEN_IS_BASE_AND_DERIVED)
0147 : boost::is_base_and_derived<boost::noncopyable, T>
0148 #elif !defined(BOOST_NO_IS_ABSTRACT)
0149 : boost::is_abstract<T>
0150 #else
0151 : boost::mpl::false_
0152 #endif
0153 {
0154 };
0155
0156 }
0157
0158 }
0159
0160
0161 #ifdef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
0162 # define BOOST_FOREACH_TAG_DEFAULT ...
0163 #else
0164 # define BOOST_FOREACH_TAG_DEFAULT boost::foreach::tag
0165 #endif
0166
0167
0168
0169
0170
0171
0172 template<typename T>
0173 inline boost::foreach::is_lightweight_proxy<T> *
0174 boost_foreach_is_lightweight_proxy(T *&, BOOST_FOREACH_TAG_DEFAULT) { return 0; }
0175
0176 template<typename T>
0177 inline boost::mpl::true_ *
0178 boost_foreach_is_lightweight_proxy(std::pair<T, T> *&, boost::foreach::tag) { return 0; }
0179
0180 template<typename T>
0181 inline boost::mpl::true_ *
0182 boost_foreach_is_lightweight_proxy(boost::iterator_range<T> *&, boost::foreach::tag) { return 0; }
0183
0184 template<typename T>
0185 inline boost::mpl::true_ *
0186 boost_foreach_is_lightweight_proxy(boost::sub_range<T> *&, boost::foreach::tag) { return 0; }
0187
0188 template<typename T>
0189 inline boost::mpl::true_ *
0190 boost_foreach_is_lightweight_proxy(T **&, boost::foreach::tag) { return 0; }
0191
0192
0193
0194
0195
0196
0197 template<typename T>
0198 inline boost::foreach::is_noncopyable<T> *
0199 boost_foreach_is_noncopyable(T *&, BOOST_FOREACH_TAG_DEFAULT) { return 0; }
0200
0201 namespace boost
0202 {
0203
0204 namespace foreach_detail_
0205 {
0206
0207
0208
0209
0210 template<typename Bool1, typename Bool2>
0211 inline boost::mpl::and_<Bool1, Bool2> *and_(Bool1 *, Bool2 *) { return 0; }
0212
0213 template<typename Bool1, typename Bool2, typename Bool3>
0214 inline boost::mpl::and_<Bool1, Bool2, Bool3> *and_(Bool1 *, Bool2 *, Bool3 *) { return 0; }
0215
0216 template<typename Bool1, typename Bool2>
0217 inline boost::mpl::or_<Bool1, Bool2> *or_(Bool1 *, Bool2 *) { return 0; }
0218
0219 template<typename Bool1, typename Bool2, typename Bool3>
0220 inline boost::mpl::or_<Bool1, Bool2, Bool3> *or_(Bool1 *, Bool2 *, Bool3 *) { return 0; }
0221
0222 template<typename Bool1>
0223 inline boost::mpl::not_<Bool1> *not_(Bool1 *) { return 0; }
0224
0225 template<typename T>
0226 inline boost::is_array<T> *is_array_(T const &) { return 0; }
0227
0228 template<typename T>
0229 inline boost::is_const<T> *is_const_(T &) { return 0; }
0230
0231 #ifndef BOOST_FOREACH_NO_RVALUE_DETECTION
0232 template<typename T>
0233 inline boost::mpl::true_ *is_const_(T const &) { return 0; }
0234 #endif
0235
0236 #ifdef BOOST_NO_CXX11_RVALUE_REFERENCES
0237 template<typename T>
0238 inline boost::mpl::false_ *is_rvalue_(T &, int) { return 0; }
0239
0240 template<typename T>
0241 inline boost::mpl::true_ *is_rvalue_(T const &, ...) { return 0; }
0242 #else
0243 template<typename T>
0244 inline boost::is_rvalue_reference<T &&> *is_rvalue_(T &&, int) { return 0; }
0245 #endif
0246
0247
0248
0249
0250 struct auto_any_base
0251 {
0252
0253
0254 operator bool() const
0255 {
0256 return false;
0257 }
0258 };
0259
0260 template<typename T>
0261 struct auto_any : auto_any_base
0262 {
0263 explicit auto_any(T const &t)
0264 : item(t)
0265 {
0266 }
0267
0268
0269
0270
0271 mutable T item;
0272 };
0273
0274 typedef auto_any_base const &auto_any_t;
0275
0276 template<typename T, typename C>
0277 inline BOOST_DEDUCED_TYPENAME boost::mpl::if_<C, T const, T>::type &auto_any_cast(auto_any_t a)
0278 {
0279 return static_cast<auto_any<T> const &>(a).item;
0280 }
0281
0282 typedef boost::mpl::true_ const_;
0283
0284
0285
0286
0287 template<typename T, typename C = boost::mpl::false_>
0288 struct type2type
0289 : boost::mpl::if_<C, T const, T>
0290 {
0291 };
0292
0293 template<typename T>
0294 struct wrap_cstr
0295 {
0296 typedef T type;
0297 };
0298
0299 template<>
0300 struct wrap_cstr<char *>
0301 {
0302 typedef wrap_cstr<char *> type;
0303 typedef char *iterator;
0304 typedef char *const_iterator;
0305 };
0306
0307 template<>
0308 struct wrap_cstr<char const *>
0309 {
0310 typedef wrap_cstr<char const *> type;
0311 typedef char const *iterator;
0312 typedef char const *const_iterator;
0313 };
0314
0315 template<>
0316 struct wrap_cstr<wchar_t *>
0317 {
0318 typedef wrap_cstr<wchar_t *> type;
0319 typedef wchar_t *iterator;
0320 typedef wchar_t *const_iterator;
0321 };
0322
0323 template<>
0324 struct wrap_cstr<wchar_t const *>
0325 {
0326 typedef wrap_cstr<wchar_t const *> type;
0327 typedef wchar_t const *iterator;
0328 typedef wchar_t const *const_iterator;
0329 };
0330
0331 template<typename T>
0332 struct is_char_array
0333 : mpl::and_<
0334 is_array<T>
0335 , mpl::or_<
0336 is_convertible<T, char const *>
0337 , is_convertible<T, wchar_t const *>
0338 >
0339 >
0340 {};
0341
0342 template<typename T, typename C = boost::mpl::false_>
0343 struct foreach_iterator
0344 {
0345
0346
0347
0348
0349
0350
0351
0352
0353
0354
0355
0356
0357 BOOST_MPL_ASSERT_MSG( (!is_char_array<T>::value), IS_THIS_AN_ARRAY_OR_A_NULL_TERMINATED_STRING, (T&) );
0358
0359
0360
0361 typedef BOOST_DEDUCED_TYPENAME wrap_cstr<T>::type container;
0362
0363 typedef BOOST_DEDUCED_TYPENAME boost::mpl::eval_if<
0364 C
0365 , range_const_iterator<container>
0366 , range_mutable_iterator<container>
0367 >::type type;
0368 };
0369
0370
0371 template<typename T, typename C = boost::mpl::false_>
0372 struct foreach_reverse_iterator
0373 {
0374
0375
0376
0377
0378
0379
0380
0381
0382
0383
0384
0385
0386 BOOST_MPL_ASSERT_MSG( (!is_char_array<T>::value), IS_THIS_AN_ARRAY_OR_A_NULL_TERMINATED_STRING, (T&) );
0387
0388
0389
0390 typedef BOOST_DEDUCED_TYPENAME wrap_cstr<T>::type container;
0391
0392 typedef BOOST_DEDUCED_TYPENAME boost::mpl::eval_if<
0393 C
0394 , range_reverse_iterator<container const>
0395 , range_reverse_iterator<container>
0396 >::type type;
0397 };
0398
0399 template<typename T, typename C = boost::mpl::false_>
0400 struct foreach_reference
0401 : iterator_reference<BOOST_DEDUCED_TYPENAME foreach_iterator<T, C>::type>
0402 {
0403 };
0404
0405
0406
0407
0408 template<typename T>
0409 inline type2type<T> *encode_type(T &, boost::false_type*) { return 0; }
0410
0411 template<typename T>
0412 inline type2type<T, const_> *encode_type(T const &, boost::true_type*) { return 0; }
0413
0414 template<typename T>
0415 inline type2type<T> *encode_type(T &, boost::mpl::false_*) { return 0; }
0416
0417 template<typename T>
0418 inline type2type<T, const_> *encode_type(T const &, boost::mpl::true_*) { return 0; }
0419
0420
0421
0422
0423 inline bool set_false(bool &b)
0424 {
0425 b = false;
0426 return false;
0427 }
0428
0429
0430
0431
0432 template<typename T>
0433 inline T *&to_ptr(T const &)
0434 {
0435 static T *t = 0;
0436 return t;
0437 }
0438
0439
0440 #if BOOST_WORKAROUND(BOOST_BORLANDC, BOOST_TESTED_AT(0x564))
0441 template<typename T,std::size_t N>
0442 inline T (*&to_ptr(T (&)[N]))[N]
0443 {
0444 static T (*t)[N] = 0;
0445 return t;
0446 }
0447
0448
0449
0450
0451 template<typename T>
0452 inline T &derefof(T *t)
0453 {
0454
0455
0456 return reinterpret_cast<T &>(
0457 *const_cast<char *>(
0458 reinterpret_cast<char const volatile *>(t)
0459 )
0460 );
0461 }
0462
0463 # define BOOST_FOREACH_DEREFOF(T) boost::foreach_detail_::derefof(*T)
0464 #else
0465 # define BOOST_FOREACH_DEREFOF(T) (*T)
0466 #endif
0467
0468 #if defined(BOOST_FOREACH_COMPILE_TIME_CONST_RVALUE_DETECTION) \
0469 && !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
0470
0471
0472
0473
0474
0475 # define BOOST_FOREACH_IS_RVALUE(COL) \
0476 boost::foreach_detail_::is_rvalue_((COL), 0)
0477
0478 #elif defined(BOOST_FOREACH_COMPILE_TIME_CONST_RVALUE_DETECTION) \
0479 && defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
0480
0481
0482
0483
0484
0485
0486
0487
0488
0489 template<typename T>
0490 struct rvalue_probe
0491 {
0492 struct private_type_ {};
0493
0494 typedef BOOST_DEDUCED_TYPENAME boost::mpl::if_<
0495 boost::mpl::or_<boost::is_abstract<T>, boost::is_array<T> >, private_type_, T
0496 >::type value_type;
0497 operator value_type() { return *reinterpret_cast<value_type *>(this); }
0498 operator T &() const { return *reinterpret_cast<T *>(const_cast<rvalue_probe *>(this)); }
0499 };
0500
0501 template<typename T>
0502 rvalue_probe<T> const make_probe(T const &)
0503 {
0504 return rvalue_probe<T>();
0505 }
0506
0507 # define BOOST_FOREACH_IS_RVALUE(COL) \
0508 boost::foreach_detail_::and_( \
0509 boost::foreach_detail_::not_(boost::foreach_detail_::is_array_(COL)) \
0510 , (true ? 0 : boost::foreach_detail_::is_rvalue_( \
0511 (true ? boost::foreach_detail_::make_probe(COL) : (COL)), 0)))
0512
0513 #elif defined(BOOST_FOREACH_RUN_TIME_CONST_RVALUE_DETECTION)
0514
0515
0516
0517
0518
0519
0520
0521
0522
0523
0524 template<typename T>
0525 struct rvalue_probe
0526 {
0527 rvalue_probe(T &t, bool &b)
0528 : value(t)
0529 , is_rvalue(b)
0530 {
0531 }
0532
0533 struct private_type_ {};
0534
0535 #ifdef BOOST_NO_IS_ABSTRACT
0536 typedef BOOST_DEDUCED_TYPENAME boost::mpl::if_<
0537 boost::is_array<T>, private_type_, T
0538 >::type value_type;
0539 #else
0540 typedef BOOST_DEDUCED_TYPENAME boost::mpl::if_<
0541 boost::mpl::or_<boost::is_abstract<T>, boost::is_array<T> >, private_type_, T
0542 >::type value_type;
0543 #endif
0544
0545 operator value_type()
0546 {
0547 this->is_rvalue = true;
0548 return this->value;
0549 }
0550
0551 operator T &() const
0552 {
0553 return this->value;
0554 }
0555
0556 private:
0557 T &value;
0558 bool &is_rvalue;
0559 };
0560
0561 template<typename T>
0562 rvalue_probe<T> make_probe(T &t, bool &b) { return rvalue_probe<T>(t, b); }
0563
0564 template<typename T>
0565 rvalue_probe<T const> make_probe(T const &t, bool &b) { return rvalue_probe<T const>(t, b); }
0566
0567
0568
0569
0570 template<typename T>
0571 struct simple_variant
0572 {
0573 simple_variant(T const *t)
0574 : is_rvalue(false)
0575 {
0576 *static_cast<T const **>(this->data.address()) = t;
0577 }
0578
0579 simple_variant(T const &t)
0580 : is_rvalue(true)
0581 {
0582 ::new(this->data.address()) T(t);
0583 }
0584
0585 simple_variant(simple_variant const &that)
0586 : is_rvalue(that.is_rvalue)
0587 {
0588 if(this->is_rvalue)
0589 ::new(this->data.address()) T(*that.get());
0590 else
0591 *static_cast<T const **>(this->data.address()) = that.get();
0592 }
0593
0594 ~simple_variant()
0595 {
0596 if(this->is_rvalue)
0597 this->get()->~T();
0598 }
0599
0600 T const *get() const
0601 {
0602 if(this->is_rvalue)
0603 return static_cast<T const *>(this->data.address());
0604 else
0605 return *static_cast<T const * const *>(this->data.address());
0606 }
0607
0608 private:
0609 enum size_type { size = sizeof(T) > sizeof(T*) ? sizeof(T) : sizeof(T*) };
0610 simple_variant &operator =(simple_variant const &);
0611 bool const is_rvalue;
0612 aligned_storage<size> data;
0613 };
0614
0615
0616
0617
0618 template<typename LValue, typename IsProxy>
0619 inline BOOST_DEDUCED_TYPENAME boost::enable_if<boost::mpl::or_<LValue, IsProxy>, IsProxy>::type *
0620 should_copy_impl(LValue *, IsProxy *, bool *)
0621 {
0622 return 0;
0623 }
0624
0625
0626 inline bool *
0627 should_copy_impl(boost::mpl::false_ *, boost::mpl::false_ *, bool *is_rvalue)
0628 {
0629 return is_rvalue;
0630 }
0631
0632 #endif
0633
0634
0635
0636
0637 template<typename T>
0638 inline auto_any<T> contain(T const &t, boost::mpl::true_ *)
0639 {
0640 return auto_any<T>(t);
0641 }
0642
0643 template<typename T>
0644 inline auto_any<T *> contain(T &t, boost::mpl::false_ *)
0645 {
0646
0647 #if BOOST_WORKAROUND(__SUNPRO_CC, BOOST_TESTED_AT(0x570))
0648 return auto_any<T *>(&t);
0649 #else
0650 return auto_any<T *>(boost::addressof(t));
0651 #endif
0652 }
0653
0654 #ifdef BOOST_FOREACH_RUN_TIME_CONST_RVALUE_DETECTION
0655 template<typename T>
0656 inline auto_any<simple_variant<T> >
0657 contain(T const &t, bool *rvalue)
0658 {
0659 return auto_any<simple_variant<T> >(*rvalue ? simple_variant<T>(t) : simple_variant<T>(&t));
0660 }
0661 #endif
0662
0663
0664
0665
0666 template<typename T, typename C>
0667 inline auto_any<BOOST_DEDUCED_TYPENAME foreach_iterator<T, C>::type>
0668 begin(auto_any_t col, type2type<T, C> *, boost::mpl::true_ *)
0669 {
0670 return auto_any<BOOST_DEDUCED_TYPENAME foreach_iterator<T, C>::type>(
0671 boost::begin(auto_any_cast<T, C>(col)));
0672 }
0673
0674 template<typename T, typename C>
0675 inline auto_any<BOOST_DEDUCED_TYPENAME foreach_iterator<T, C>::type>
0676 begin(auto_any_t col, type2type<T, C> *, boost::mpl::false_ *)
0677 {
0678 typedef BOOST_DEDUCED_TYPENAME type2type<T, C>::type type;
0679 typedef BOOST_DEDUCED_TYPENAME foreach_iterator<T, C>::type iterator;
0680 return auto_any<BOOST_DEDUCED_TYPENAME foreach_iterator<T, C>::type>(
0681 iterator(boost::begin(BOOST_FOREACH_DEREFOF((auto_any_cast<type *, boost::mpl::false_>(col))))));
0682 }
0683
0684 #ifdef BOOST_FOREACH_RUN_TIME_CONST_RVALUE_DETECTION
0685 template<typename T>
0686 inline auto_any<BOOST_DEDUCED_TYPENAME foreach_iterator<T, const_>::type>
0687 begin(auto_any_t col, type2type<T, const_> *, bool *)
0688 {
0689 return auto_any<BOOST_DEDUCED_TYPENAME foreach_iterator<T, const_>::type>(
0690 boost::begin(*auto_any_cast<simple_variant<T>, boost::mpl::false_>(col).get()));
0691 }
0692 #endif
0693
0694 #ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
0695 template<typename T, typename C>
0696 inline auto_any<T *>
0697 begin(auto_any_t col, type2type<T *, C> *, boost::mpl::true_ *)
0698 {
0699 return auto_any<T *>(auto_any_cast<T *, boost::mpl::false_>(col));
0700 }
0701 #endif
0702
0703
0704
0705
0706 template<typename T, typename C>
0707 inline auto_any<BOOST_DEDUCED_TYPENAME foreach_iterator<T, C>::type>
0708 end(auto_any_t col, type2type<T, C> *, boost::mpl::true_ *)
0709 {
0710 return auto_any<BOOST_DEDUCED_TYPENAME foreach_iterator<T, C>::type>(
0711 boost::end(auto_any_cast<T, C>(col)));
0712 }
0713
0714 template<typename T, typename C>
0715 inline auto_any<BOOST_DEDUCED_TYPENAME foreach_iterator<T, C>::type>
0716 end(auto_any_t col, type2type<T, C> *, boost::mpl::false_ *)
0717 {
0718 typedef BOOST_DEDUCED_TYPENAME type2type<T, C>::type type;
0719 typedef BOOST_DEDUCED_TYPENAME foreach_iterator<T, C>::type iterator;
0720 return auto_any<BOOST_DEDUCED_TYPENAME foreach_iterator<T, C>::type>(
0721 iterator(boost::end(BOOST_FOREACH_DEREFOF((auto_any_cast<type *, boost::mpl::false_>(col))))));
0722 }
0723
0724 #ifdef BOOST_FOREACH_RUN_TIME_CONST_RVALUE_DETECTION
0725 template<typename T>
0726 inline auto_any<BOOST_DEDUCED_TYPENAME foreach_iterator<T, const_>::type>
0727 end(auto_any_t col, type2type<T, const_> *, bool *)
0728 {
0729 return auto_any<BOOST_DEDUCED_TYPENAME foreach_iterator<T, const_>::type>(
0730 boost::end(*auto_any_cast<simple_variant<T>, boost::mpl::false_>(col).get()));
0731 }
0732 #endif
0733
0734 #ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
0735 template<typename T, typename C>
0736 inline auto_any<int>
0737 end(auto_any_t, type2type<T *, C> *, boost::mpl::true_ *)
0738 {
0739 return auto_any<int>(0);
0740 }
0741 #endif
0742
0743
0744
0745
0746 template<typename T, typename C>
0747 inline bool done(auto_any_t cur, auto_any_t end, type2type<T, C> *)
0748 {
0749 typedef BOOST_DEDUCED_TYPENAME foreach_iterator<T, C>::type iter_t;
0750 return auto_any_cast<iter_t, boost::mpl::false_>(cur) == auto_any_cast<iter_t, boost::mpl::false_>(end);
0751 }
0752
0753 #ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
0754 template<typename T, typename C>
0755 inline bool done(auto_any_t cur, auto_any_t, type2type<T *, C> *)
0756 {
0757 return ! *auto_any_cast<T *, boost::mpl::false_>(cur);
0758 }
0759 #endif
0760
0761
0762
0763
0764 template<typename T, typename C>
0765 inline void next(auto_any_t cur, type2type<T, C> *)
0766 {
0767 typedef BOOST_DEDUCED_TYPENAME foreach_iterator<T, C>::type iter_t;
0768 ++auto_any_cast<iter_t, boost::mpl::false_>(cur);
0769 }
0770
0771
0772
0773
0774 template<typename T, typename C>
0775 inline BOOST_DEDUCED_TYPENAME foreach_reference<T, C>::type
0776 deref(auto_any_t cur, type2type<T, C> *)
0777 {
0778 typedef BOOST_DEDUCED_TYPENAME foreach_iterator<T, C>::type iter_t;
0779 return *auto_any_cast<iter_t, boost::mpl::false_>(cur);
0780 }
0781
0782
0783
0784
0785 template<typename T, typename C>
0786 inline auto_any<BOOST_DEDUCED_TYPENAME foreach_reverse_iterator<T, C>::type>
0787 rbegin(auto_any_t col, type2type<T, C> *, boost::mpl::true_ *)
0788 {
0789 return auto_any<BOOST_DEDUCED_TYPENAME foreach_reverse_iterator<T, C>::type>(
0790 boost::rbegin(auto_any_cast<T, C>(col)));
0791 }
0792
0793 template<typename T, typename C>
0794 inline auto_any<BOOST_DEDUCED_TYPENAME foreach_reverse_iterator<T, C>::type>
0795 rbegin(auto_any_t col, type2type<T, C> *, boost::mpl::false_ *)
0796 {
0797 typedef BOOST_DEDUCED_TYPENAME type2type<T, C>::type type;
0798 typedef BOOST_DEDUCED_TYPENAME foreach_reverse_iterator<T, C>::type iterator;
0799 return auto_any<BOOST_DEDUCED_TYPENAME foreach_reverse_iterator<T, C>::type>(
0800 iterator(boost::rbegin(BOOST_FOREACH_DEREFOF((auto_any_cast<type *, boost::mpl::false_>(col))))));
0801 }
0802
0803 #ifdef BOOST_FOREACH_RUN_TIME_CONST_RVALUE_DETECTION
0804 template<typename T>
0805 inline auto_any<BOOST_DEDUCED_TYPENAME foreach_reverse_iterator<T, const_>::type>
0806 rbegin(auto_any_t col, type2type<T, const_> *, bool *)
0807 {
0808 return auto_any<BOOST_DEDUCED_TYPENAME foreach_reverse_iterator<T, const_>::type>(
0809 boost::rbegin(*auto_any_cast<simple_variant<T>, boost::mpl::false_>(col).get()));
0810 }
0811 #endif
0812
0813 #ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
0814 template<typename T, typename C>
0815 inline auto_any<reverse_iterator<T *> >
0816 rbegin(auto_any_t col, type2type<T *, C> *, boost::mpl::true_ *)
0817 {
0818 T *p = auto_any_cast<T *, boost::mpl::false_>(col);
0819 while(0 != *p)
0820 ++p;
0821 return auto_any<reverse_iterator<T *> >(reverse_iterator<T *>(p));
0822 }
0823 #endif
0824
0825
0826
0827
0828 template<typename T, typename C>
0829 inline auto_any<BOOST_DEDUCED_TYPENAME foreach_reverse_iterator<T, C>::type>
0830 rend(auto_any_t col, type2type<T, C> *, boost::mpl::true_ *)
0831 {
0832 return auto_any<BOOST_DEDUCED_TYPENAME foreach_reverse_iterator<T, C>::type>(
0833 boost::rend(auto_any_cast<T, C>(col)));
0834 }
0835
0836 template<typename T, typename C>
0837 inline auto_any<BOOST_DEDUCED_TYPENAME foreach_reverse_iterator<T, C>::type>
0838 rend(auto_any_t col, type2type<T, C> *, boost::mpl::false_ *)
0839 {
0840 typedef BOOST_DEDUCED_TYPENAME type2type<T, C>::type type;
0841 typedef BOOST_DEDUCED_TYPENAME foreach_reverse_iterator<T, C>::type iterator;
0842 return auto_any<BOOST_DEDUCED_TYPENAME foreach_reverse_iterator<T, C>::type>(
0843 iterator(boost::rend(BOOST_FOREACH_DEREFOF((auto_any_cast<type *, boost::mpl::false_>(col))))));
0844 }
0845
0846 #ifdef BOOST_FOREACH_RUN_TIME_CONST_RVALUE_DETECTION
0847 template<typename T>
0848 inline auto_any<BOOST_DEDUCED_TYPENAME foreach_reverse_iterator<T, const_>::type>
0849 rend(auto_any_t col, type2type<T, const_> *, bool *)
0850 {
0851 return auto_any<BOOST_DEDUCED_TYPENAME foreach_reverse_iterator<T, const_>::type>(
0852 boost::rend(*auto_any_cast<simple_variant<T>, boost::mpl::false_>(col).get()));
0853 }
0854 #endif
0855
0856 #ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
0857 template<typename T, typename C>
0858 inline auto_any<reverse_iterator<T *> >
0859 rend(auto_any_t col, type2type<T *, C> *, boost::mpl::true_ *)
0860 {
0861 return auto_any<reverse_iterator<T *> >(
0862 reverse_iterator<T *>(auto_any_cast<T *, boost::mpl::false_>(col)));
0863 }
0864 #endif
0865
0866
0867
0868
0869 template<typename T, typename C>
0870 inline bool rdone(auto_any_t cur, auto_any_t end, type2type<T, C> *)
0871 {
0872 typedef BOOST_DEDUCED_TYPENAME foreach_reverse_iterator<T, C>::type iter_t;
0873 return auto_any_cast<iter_t, boost::mpl::false_>(cur) == auto_any_cast<iter_t, boost::mpl::false_>(end);
0874 }
0875
0876
0877
0878
0879 template<typename T, typename C>
0880 inline void rnext(auto_any_t cur, type2type<T, C> *)
0881 {
0882 typedef BOOST_DEDUCED_TYPENAME foreach_reverse_iterator<T, C>::type iter_t;
0883 ++auto_any_cast<iter_t, boost::mpl::false_>(cur);
0884 }
0885
0886
0887
0888
0889 template<typename T, typename C>
0890 inline BOOST_DEDUCED_TYPENAME foreach_reference<T, C>::type
0891 rderef(auto_any_t cur, type2type<T, C> *)
0892 {
0893 typedef BOOST_DEDUCED_TYPENAME foreach_reverse_iterator<T, C>::type iter_t;
0894 return *auto_any_cast<iter_t, boost::mpl::false_>(cur);
0895 }
0896
0897 }
0898 }
0899
0900
0901 #if BOOST_WORKAROUND(BOOST_MSVC, >= 1400)
0902 # define BOOST_FOREACH_SUPPRESS_WARNINGS() __pragma(warning(suppress:6001))
0903 #else
0904 # define BOOST_FOREACH_SUPPRESS_WARNINGS()
0905 #endif
0906
0907
0908
0909
0910 #if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1500))
0911
0912
0913 # define BOOST_FOREACH_ID(x) x
0914 #else
0915 # define BOOST_FOREACH_ID(x) BOOST_PP_CAT(x, __LINE__)
0916 #endif
0917
0918
0919 #define BOOST_FOREACH_TYPEOF(COL) \
0920 (true ? BOOST_FOREACH_NULL : boost::foreach_detail_::encode_type(COL, boost::foreach_detail_::is_const_(COL)))
0921
0922
0923 #define BOOST_FOREACH_IS_NONCOPYABLE(COL) \
0924 boost_foreach_is_noncopyable( \
0925 boost::foreach_detail_::to_ptr(COL) \
0926 , boost_foreach_argument_dependent_lookup_hack_value)
0927
0928
0929 #define BOOST_FOREACH_IS_LIGHTWEIGHT_PROXY(COL) \
0930 boost::foreach_detail_::and_( \
0931 boost::foreach_detail_::not_(BOOST_FOREACH_IS_NONCOPYABLE(COL)) \
0932 , boost_foreach_is_lightweight_proxy( \
0933 boost::foreach_detail_::to_ptr(COL) \
0934 , boost_foreach_argument_dependent_lookup_hack_value))
0935
0936 #if defined(BOOST_FOREACH_COMPILE_TIME_CONST_RVALUE_DETECTION)
0937
0938
0939
0940
0941
0942 # define BOOST_FOREACH_PREAMBLE() \
0943 BOOST_FOREACH_SUPPRESS_WARNINGS()
0944
0945
0946 # define BOOST_FOREACH_EVALUATE(COL) \
0947 (COL)
0948
0949 # define BOOST_FOREACH_SHOULD_COPY(COL) \
0950 (true ? BOOST_FOREACH_NULL : boost::foreach_detail_::or_( \
0951 BOOST_FOREACH_IS_RVALUE(COL) \
0952 , BOOST_FOREACH_IS_LIGHTWEIGHT_PROXY(COL)))
0953
0954 #elif defined(BOOST_FOREACH_RUN_TIME_CONST_RVALUE_DETECTION)
0955
0956
0957
0958
0959
0960 # define BOOST_FOREACH_PREAMBLE() \
0961 BOOST_FOREACH_SUPPRESS_WARNINGS() \
0962 if (bool BOOST_FOREACH_ID(_foreach_is_rvalue) = false) {} else
0963
0964
0965 # define BOOST_FOREACH_EVALUATE(COL) \
0966 (true ? boost::foreach_detail_::make_probe((COL), BOOST_FOREACH_ID(_foreach_is_rvalue)) : (COL))
0967
0968
0969
0970
0971 # define BOOST_FOREACH_SHOULD_COPY(COL) \
0972 (boost::foreach_detail_::should_copy_impl( \
0973 true ? BOOST_FOREACH_NULL : boost::foreach_detail_::or_( \
0974 boost::foreach_detail_::is_array_(COL) \
0975 , BOOST_FOREACH_IS_NONCOPYABLE(COL) \
0976 , boost::foreach_detail_::not_(boost::foreach_detail_::is_const_(COL))) \
0977 , true ? BOOST_FOREACH_NULL : BOOST_FOREACH_IS_LIGHTWEIGHT_PROXY(COL) \
0978 , &BOOST_FOREACH_ID(_foreach_is_rvalue)))
0979
0980 #elif !defined(BOOST_FOREACH_NO_RVALUE_DETECTION)
0981
0982
0983
0984
0985
0986 # define BOOST_FOREACH_PREAMBLE() \
0987 BOOST_FOREACH_SUPPRESS_WARNINGS()
0988
0989
0990 # define BOOST_FOREACH_EVALUATE(COL) \
0991 (COL)
0992
0993
0994
0995 # define BOOST_FOREACH_SHOULD_COPY(COL) \
0996 (true ? BOOST_FOREACH_NULL : boost::foreach_detail_::or_( \
0997 boost::foreach_detail_::is_rvalue_((COL), 0) \
0998 , BOOST_FOREACH_IS_LIGHTWEIGHT_PROXY(COL)))
0999
1000 #else
1001
1002
1003
1004
1005
1006 # define BOOST_FOREACH_PREAMBLE() \
1007 BOOST_FOREACH_SUPPRESS_WARNINGS()
1008
1009
1010 # define BOOST_FOREACH_EVALUATE(COL) \
1011 (COL)
1012
1013
1014 # define BOOST_FOREACH_SHOULD_COPY(COL) \
1015 (true ? BOOST_FOREACH_NULL : BOOST_FOREACH_IS_LIGHTWEIGHT_PROXY(COL))
1016
1017 #endif
1018
1019 #define BOOST_FOREACH_CONTAIN(COL) \
1020 boost::foreach_detail_::contain( \
1021 BOOST_FOREACH_EVALUATE(COL) \
1022 , BOOST_FOREACH_SHOULD_COPY(COL))
1023
1024 #define BOOST_FOREACH_BEGIN(COL) \
1025 boost::foreach_detail_::begin( \
1026 BOOST_FOREACH_ID(_foreach_col) \
1027 , BOOST_FOREACH_TYPEOF(COL) \
1028 , BOOST_FOREACH_SHOULD_COPY(COL))
1029
1030 #define BOOST_FOREACH_END(COL) \
1031 boost::foreach_detail_::end( \
1032 BOOST_FOREACH_ID(_foreach_col) \
1033 , BOOST_FOREACH_TYPEOF(COL) \
1034 , BOOST_FOREACH_SHOULD_COPY(COL))
1035
1036 #define BOOST_FOREACH_DONE(COL) \
1037 boost::foreach_detail_::done( \
1038 BOOST_FOREACH_ID(_foreach_cur) \
1039 , BOOST_FOREACH_ID(_foreach_end) \
1040 , BOOST_FOREACH_TYPEOF(COL))
1041
1042 #define BOOST_FOREACH_NEXT(COL) \
1043 boost::foreach_detail_::next( \
1044 BOOST_FOREACH_ID(_foreach_cur) \
1045 , BOOST_FOREACH_TYPEOF(COL))
1046
1047 #define BOOST_FOREACH_DEREF(COL) \
1048 boost::foreach_detail_::deref( \
1049 BOOST_FOREACH_ID(_foreach_cur) \
1050 , BOOST_FOREACH_TYPEOF(COL))
1051
1052 #define BOOST_FOREACH_RBEGIN(COL) \
1053 boost::foreach_detail_::rbegin( \
1054 BOOST_FOREACH_ID(_foreach_col) \
1055 , BOOST_FOREACH_TYPEOF(COL) \
1056 , BOOST_FOREACH_SHOULD_COPY(COL))
1057
1058 #define BOOST_FOREACH_REND(COL) \
1059 boost::foreach_detail_::rend( \
1060 BOOST_FOREACH_ID(_foreach_col) \
1061 , BOOST_FOREACH_TYPEOF(COL) \
1062 , BOOST_FOREACH_SHOULD_COPY(COL))
1063
1064 #define BOOST_FOREACH_RDONE(COL) \
1065 boost::foreach_detail_::rdone( \
1066 BOOST_FOREACH_ID(_foreach_cur) \
1067 , BOOST_FOREACH_ID(_foreach_end) \
1068 , BOOST_FOREACH_TYPEOF(COL))
1069
1070 #define BOOST_FOREACH_RNEXT(COL) \
1071 boost::foreach_detail_::rnext( \
1072 BOOST_FOREACH_ID(_foreach_cur) \
1073 , BOOST_FOREACH_TYPEOF(COL))
1074
1075 #define BOOST_FOREACH_RDEREF(COL) \
1076 boost::foreach_detail_::rderef( \
1077 BOOST_FOREACH_ID(_foreach_cur) \
1078 , BOOST_FOREACH_TYPEOF(COL))
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106 #define BOOST_FOREACH(VAR, COL) \
1107 BOOST_FOREACH_PREAMBLE() \
1108 if (boost::foreach_detail_::auto_any_t BOOST_FOREACH_ID(_foreach_col) = BOOST_FOREACH_CONTAIN(COL)) {} else \
1109 if (boost::foreach_detail_::auto_any_t BOOST_FOREACH_ID(_foreach_cur) = BOOST_FOREACH_BEGIN(COL)) {} else \
1110 if (boost::foreach_detail_::auto_any_t BOOST_FOREACH_ID(_foreach_end) = BOOST_FOREACH_END(COL)) {} else \
1111 for (bool BOOST_FOREACH_ID(_foreach_continue) = true; \
1112 BOOST_FOREACH_ID(_foreach_continue) && !BOOST_FOREACH_DONE(COL); \
1113 BOOST_FOREACH_ID(_foreach_continue) ? BOOST_FOREACH_NEXT(COL) : (void)0) \
1114 if (boost::foreach_detail_::set_false(BOOST_FOREACH_ID(_foreach_continue))) {} else \
1115 for (VAR = BOOST_FOREACH_DEREF(COL); !BOOST_FOREACH_ID(_foreach_continue); BOOST_FOREACH_ID(_foreach_continue) = true)
1116
1117
1118
1119
1120
1121
1122
1123
1124 #define BOOST_REVERSE_FOREACH(VAR, COL) \
1125 BOOST_FOREACH_PREAMBLE() \
1126 if (boost::foreach_detail_::auto_any_t BOOST_FOREACH_ID(_foreach_col) = BOOST_FOREACH_CONTAIN(COL)) {} else \
1127 if (boost::foreach_detail_::auto_any_t BOOST_FOREACH_ID(_foreach_cur) = BOOST_FOREACH_RBEGIN(COL)) {} else \
1128 if (boost::foreach_detail_::auto_any_t BOOST_FOREACH_ID(_foreach_end) = BOOST_FOREACH_REND(COL)) {} else \
1129 for (bool BOOST_FOREACH_ID(_foreach_continue) = true; \
1130 BOOST_FOREACH_ID(_foreach_continue) && !BOOST_FOREACH_RDONE(COL); \
1131 BOOST_FOREACH_ID(_foreach_continue) ? BOOST_FOREACH_RNEXT(COL) : (void)0) \
1132 if (boost::foreach_detail_::set_false(BOOST_FOREACH_ID(_foreach_continue))) {} else \
1133 for (VAR = BOOST_FOREACH_RDEREF(COL); !BOOST_FOREACH_ID(_foreach_continue); BOOST_FOREACH_ID(_foreach_continue) = true)
1134
1135 #endif