Ticket #5475: foreach_use_cxx11_v2.patch

File foreach_use_cxx11_v2.patch, 49.2 KB (added by Michel Morin, 10 years ago)

Updated patch of foreach_use_cxx11.patch. With this patch, we can iterate over noncopyable temporary ranges on VC++ 11 as well.

  • boost/foreach.hpp

     
    3030#include <boost/config.hpp>
    3131#include <boost/detail/workaround.hpp>
    3232
     33// Some compilers support rvalue references and auto type deduction.
     34// With these C++11 features, temporary collections can be bound to
     35// rvalue references and their lifetime is extended. No copy/move is needed.
     36#if !defined(BOOST_NO_RVALUE_REFERENCES) && !defined(BOOST_NO_AUTO_DECLARATIONS)                 \
     37 && !(BOOST_WORKAROUND(__GNUC__, == 4) && (__GNUC_MINOR__ <= 6) && !defined(BOOST_INTEL) &&      \
     38                                                                   !defined(BOOST_CLANG))        \
     39 && !BOOST_WORKAROUND(BOOST_MSVC, == 1600)
     40# define BOOST_FOREACH_USE_CXX11
     41// gcc 4.4-4.6 have bugs in auto type deduction. We use workaround codes
     42// on these compilers.
     43#elif !defined(BOOST_NO_RVALUE_REFERENCES) && !defined(BOOST_NO_AUTO_DECLARATIONS)               \
     44 && (BOOST_WORKAROUND(__GNUC__, == 4) && (__GNUC_MINOR__ <= 6) && !defined(BOOST_INTEL) &&       \
     45                                                                     !defined(BOOST_CLANG))
     46# define BOOST_FOREACH_USE_CXX11_GCC_WORKAROUND
    3347// Some compilers let us detect even const-qualified rvalues at compile-time
    34 #if !defined(BOOST_NO_RVALUE_REFERENCES)                                                         \
     48#elif !defined(BOOST_NO_RVALUE_REFERENCES)                                                       \
    3549 || BOOST_WORKAROUND(BOOST_MSVC, >= 1310) && !defined(_PREFAST_)                                 \
    3650 || (BOOST_WORKAROUND(__GNUC__, == 4) && (__GNUC_MINOR__ <= 5) && !defined(BOOST_INTEL) &&       \
    3751                                                                  !defined(BOOST_CLANG))         \
     
    88102#include <boost/utility/addressof.hpp>
    89103#include <boost/foreach_fwd.hpp>
    90104
     105#if defined(BOOST_FOREACH_USE_CXX11) || defined(BOOST_FOREACH_USE_CXX11_GCC_WORKAROUND)
     106# include <boost/utility/enable_if.hpp>
     107# include <boost/type_traits/remove_const.hpp>
     108#endif
     109
    91110#ifdef BOOST_FOREACH_RUN_TIME_CONST_RVALUE_DETECTION
    92111# include <new>
    93112# include <boost/aligned_storage.hpp>
     
    95114# include <boost/type_traits/remove_const.hpp>
    96115#endif
    97116
     117#if !defined(BOOST_FOREACH_USE_CXX11) && !defined(BOOST_FOREACH_USE_CXX11_GCC_WORKAROUND)
    98118namespace boost
    99119{
    100120
     
    153173} // namespace boost
    154174
    155175// vc6/7 needs help ordering the following overloads
    156 #ifdef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
    157 # define BOOST_FOREACH_TAG_DEFAULT ...
    158 #else
    159 # define BOOST_FOREACH_TAG_DEFAULT boost::foreach::tag
    160 #endif
     176# ifdef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
     177#  define BOOST_FOREACH_TAG_DEFAULT ...
     178# else
     179#  define BOOST_FOREACH_TAG_DEFAULT boost::foreach::tag
     180# endif
    161181
    162182///////////////////////////////////////////////////////////////////////////////
    163183// boost_foreach_is_lightweight_proxy
     
    192212template<typename T>
    193213inline boost::foreach::is_noncopyable<T> *
    194214boost_foreach_is_noncopyable(T *&, BOOST_FOREACH_TAG_DEFAULT) { return 0; }
     215#endif
    195216
    196217namespace boost
    197218{
     
    199220namespace foreach_detail_
    200221{
    201222
     223#if !defined(BOOST_FOREACH_USE_CXX11) && !defined(BOOST_FOREACH_USE_CXX11_GCC_WORKAROUND)
    202224///////////////////////////////////////////////////////////////////////////////
    203225// Define some utilities for assessing the properties of expressions
    204226//
     
    223245template<typename T>
    224246inline boost::is_const<T> *is_const_(T &) { return 0; }
    225247
    226 #ifndef BOOST_FOREACH_NO_RVALUE_DETECTION
     248# ifndef BOOST_FOREACH_NO_RVALUE_DETECTION
    227249template<typename T>
    228250inline boost::mpl::true_ *is_const_(T const &) { return 0; }
    229 #endif
     251# endif
    230252
    231 #ifdef BOOST_NO_RVALUE_REFERENCES
     253# ifdef BOOST_NO_RVALUE_REFERENCES
    232254template<typename T>
    233255inline boost::mpl::false_ *is_rvalue_(T &, int) { return 0; }
    234256
    235257template<typename T>
    236258inline boost::mpl::true_ *is_rvalue_(T const &, ...) { return 0; }
    237 #else
     259# else
    238260template<typename T>
    239261inline boost::is_rvalue_reference<T &&> *is_rvalue_(T &&, int) { return 0; }
     262# endif
    240263#endif
    241264
     265#if !defined(BOOST_FOREACH_USE_CXX11)
    242266///////////////////////////////////////////////////////////////////////////////
    243267// auto_any_t/auto_any
    244268//  General utility for putting an object of any type into automatic storage
     
    268292
    269293typedef auto_any_base const &auto_any_t;
    270294
     295# if defined(BOOST_FOREACH_USE_CXX11_GCC_WORKAROUND)
     296template<typename T>
     297inline T &auto_any_cast(auto_any_t a)
     298{
     299    return static_cast<auto_any<T> const &>(a).item;
     300}
     301# else
    271302template<typename T, typename C>
    272303inline BOOST_DEDUCED_TYPENAME boost::mpl::if_<C, T const, T>::type &auto_any_cast(auto_any_t a)
    273304{
    274305    return static_cast<auto_any<T> const &>(a).item;
    275306}
     307# endif
    276308
     309# if defined(BOOST_FOREACH_USE_CXX11_GCC_WORKAROUND)
     310template<typename T>
     311inline auto_any<T> make_auto_any(T t)
     312{
     313    return auto_any<T>(t);
     314}
     315# endif
     316#endif
     317
     318#if !defined(BOOST_FOREACH_USE_CXX11) && !defined(BOOST_FOREACH_USE_CXX11_GCC_WORKAROUND)
    277319typedef boost::mpl::true_ const_;
    278320
    279321///////////////////////////////////////////////////////////////////////////////
     
    284326  : boost::mpl::if_<C, T const, T>
    285327{
    286328};
     329#endif
    287330
    288331template<typename T>
    289332struct wrap_cstr
     
    334377    >
    335378{};
    336379
    337 template<typename T, typename C = boost::mpl::false_>
     380template<typename T, typename C>
    338381struct foreach_iterator
    339382{
    340383    // **** READ THIS IF YOUR COMPILE BREAKS HERE ****
     
    364407    >::type type;
    365408};
    366409
     410#if defined(BOOST_FOREACH_USE_CXX11) || defined(BOOST_FOREACH_USE_CXX11_GCC_WORKAROUND)
     411// just a shortcut for foreach_iterator<..., ...>
     412template<typename T>
     413struct foreach_iterator_
     414  : foreach_iterator<typename boost::remove_const<T>::type, boost::is_const<T> >
     415{
     416};
     417#endif
    367418
    368 template<typename T, typename C = boost::mpl::false_>
     419template<typename T, typename C>
    369420struct foreach_reverse_iterator
    370421{
    371422    // **** READ THIS IF YOUR COMPILE BREAKS HERE ****
     
    395446    >::type type;
    396447};
    397448
    398 template<typename T, typename C = boost::mpl::false_>
     449#if defined(BOOST_FOREACH_USE_CXX11) || defined(BOOST_FOREACH_USE_CXX11_GCC_WORKAROUND)
     450// just a shortcut for foreach_reverse_iterator<..., ...>
     451template<typename T>
     452struct foreach_reverse_iterator_
     453  : foreach_reverse_iterator<typename boost::remove_const<T>::type, boost::is_const<T> >
     454{
     455};
     456#endif
     457
     458template<typename T, typename C>
    399459struct foreach_reference
    400460  : iterator_reference<BOOST_DEDUCED_TYPENAME foreach_iterator<T, C>::type>
    401461{
    402462};
    403463
     464#if defined(BOOST_FOREACH_USE_CXX11) || defined(BOOST_FOREACH_USE_CXX11_GCC_WORKAROUND)
     465// just a shortcut for foreach_reference<..., ...>
     466template<typename T>
     467struct foreach_reference_
     468  : foreach_reference<typename boost::remove_const<T>::type, boost::is_const<T> >
     469{
     470};
     471#endif
     472
     473#if !defined(BOOST_FOREACH_USE_CXX11) && !defined(BOOST_FOREACH_USE_CXX11_GCC_WORKAROUND)
    404474///////////////////////////////////////////////////////////////////////////////
    405475// encode_type
    406476//
     
    430500}
    431501
    432502// Borland needs a little extra help with arrays
    433 #if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
     503# if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
    434504template<typename T,std::size_t N>
    435505inline T (*&to_ptr(T (&)[N]))[N]
    436506{
    437507    static T (*t)[N] = 0;
    438508    return t;
    439509}
    440 #endif
     510# endif
    441511
    442512///////////////////////////////////////////////////////////////////////////////
    443513// derefof
     
    454524    );
    455525}
    456526
    457 #if defined(BOOST_FOREACH_COMPILE_TIME_CONST_RVALUE_DETECTION)                                  \
    458  && !defined(BOOST_NO_RVALUE_REFERENCES)
     527# if defined(BOOST_FOREACH_COMPILE_TIME_CONST_RVALUE_DETECTION)                                 \
     528  && !defined(BOOST_NO_RVALUE_REFERENCES)
    459529///////////////////////////////////////////////////////////////////////////////
    460530// Rvalue references makes it drop-dead simple to detect at compile time
    461531// whether an expression is an rvalue.
    462532///////////////////////////////////////////////////////////////////////////////
    463533
    464 # define BOOST_FOREACH_IS_RVALUE(COL)                                                           \
     534#  define BOOST_FOREACH_IS_RVALUE(COL)                                                          \
    465535    boost::foreach_detail_::is_rvalue_((COL), 0)
    466536
    467 #elif defined(BOOST_FOREACH_COMPILE_TIME_CONST_RVALUE_DETECTION)                                \
    468  && defined(BOOST_NO_RVALUE_REFERENCES)
     537# elif defined(BOOST_FOREACH_COMPILE_TIME_CONST_RVALUE_DETECTION)                               \
     538  && defined(BOOST_NO_RVALUE_REFERENCES)
    469539///////////////////////////////////////////////////////////////////////////////
    470540// Detect at compile-time whether an expression yields an rvalue or
    471541// an lvalue. This is rather non-standard, but some popular compilers
     
    493563    return rvalue_probe<T>();
    494564}
    495565
    496 # define BOOST_FOREACH_IS_RVALUE(COL)                                                           \
     566#  define BOOST_FOREACH_IS_RVALUE(COL)                                                          \
    497567    boost::foreach_detail_::and_(                                                               \
    498568        boost::foreach_detail_::not_(boost::foreach_detail_::is_array_(COL))                    \
    499569      , (true ? 0 : boost::foreach_detail_::is_rvalue_(                                         \
    500570            (true ? boost::foreach_detail_::make_probe(COL) : (COL)), 0)))
    501571
    502 #elif defined(BOOST_FOREACH_RUN_TIME_CONST_RVALUE_DETECTION)
     572# elif defined(BOOST_FOREACH_RUN_TIME_CONST_RVALUE_DETECTION)
    503573///////////////////////////////////////////////////////////////////////////////
    504574// Detect at run-time whether an expression yields an rvalue
    505575// or an lvalue. This is 100% standard C++, but not all compilers
     
    618688    return is_rvalue;
    619689}
    620690
     691# endif
    621692#endif
    622693
    623694///////////////////////////////////////////////////////////////////////////////
    624695// contain
    625696//
     697#if !defined(BOOST_FOREACH_USE_CXX11) && !defined(BOOST_FOREACH_USE_CXX11_GCC_WORKAROUND)
    626698template<typename T>
    627699inline auto_any<T> contain(T const &t, boost::mpl::true_ *) // rvalue
    628700{
     
    640712    #endif
    641713}
    642714
    643 #ifdef BOOST_FOREACH_RUN_TIME_CONST_RVALUE_DETECTION
     715# ifdef BOOST_FOREACH_RUN_TIME_CONST_RVALUE_DETECTION
    644716template<typename T>
    645717inline auto_any<simple_variant<T> >
    646718contain(T const &t, bool *rvalue)
    647719{
    648720    return auto_any<simple_variant<T> >(*rvalue ? simple_variant<T>(t) : simple_variant<T>(&t));
    649721}
     722# endif
    650723#endif
    651724
    652725/////////////////////////////////////////////////////////////////////////////
    653726// begin
    654727//
     728#if defined(BOOST_FOREACH_USE_CXX11) || defined(BOOST_FOREACH_USE_CXX11_GCC_WORKAROUND)
     729template<typename T>
     730inline typename boost::disable_if<
     731    boost::is_pointer<T>
     732  , typename foreach_iterator_<T>::type
     733>::type
     734begin(T &col)
     735{
     736    return boost::begin(col);
     737}
     738
     739template<typename T>
     740inline typename boost::enable_if<
     741    boost::is_pointer<T>
     742  , typename foreach_iterator_<T>::type
     743>::type
     744begin(T &col) // null-terminated C-style strings
     745{
     746    return col;
     747}
     748
     749#else
    655750template<typename T, typename C>
    656751inline auto_any<BOOST_DEDUCED_TYPENAME foreach_iterator<T, C>::type>
    657752begin(auto_any_t col, type2type<T, C> *, boost::mpl::true_ *) // rvalue
     
    670765        iterator(boost::begin(derefof(auto_any_cast<type *, boost::mpl::false_>(col)))));
    671766}
    672767
    673 #ifdef BOOST_FOREACH_RUN_TIME_CONST_RVALUE_DETECTION
     768# ifdef BOOST_FOREACH_RUN_TIME_CONST_RVALUE_DETECTION
    674769template<typename T>
    675770inline auto_any<BOOST_DEDUCED_TYPENAME foreach_iterator<T, const_>::type>
    676771begin(auto_any_t col, type2type<T, const_> *, bool *)
     
    678773    return auto_any<BOOST_DEDUCED_TYPENAME foreach_iterator<T, const_>::type>(
    679774        boost::begin(*auto_any_cast<simple_variant<T>, boost::mpl::false_>(col).get()));
    680775}
    681 #endif
     776# endif
    682777
    683 #ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
     778# ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
    684779template<typename T, typename C>
    685780inline auto_any<T *>
    686781begin(auto_any_t col, type2type<T *, C> *, boost::mpl::true_ *) // null-terminated C-style strings
    687782{
    688783    return auto_any<T *>(auto_any_cast<T *, boost::mpl::false_>(col));
    689784}
     785# endif
    690786#endif
    691787
    692788///////////////////////////////////////////////////////////////////////////////
    693789// end
    694790//
     791#if defined(BOOST_FOREACH_USE_CXX11) || defined(BOOST_FOREACH_USE_CXX11_GCC_WORKAROUND)
     792template<typename T>
     793inline typename boost::disable_if<
     794    boost::is_pointer<T>
     795  , typename foreach_iterator_<T>::type
     796>::type
     797end(T &col)
     798{
     799    return boost::end(col);
     800}
     801
     802template<typename T>
     803inline typename boost::enable_if<
     804    boost::is_pointer<T>
     805  , typename foreach_iterator_<T>::type
     806>::type
     807end(T &col) // null-terminated C-style strings
     808{
     809    return 0;
     810}
     811
     812#else
    695813template<typename T, typename C>
    696814inline auto_any<BOOST_DEDUCED_TYPENAME foreach_iterator<T, C>::type>
    697815end(auto_any_t col, type2type<T, C> *, boost::mpl::true_ *) // rvalue
     
    710828        iterator(boost::end(derefof(auto_any_cast<type *, boost::mpl::false_>(col)))));
    711829}
    712830
    713 #ifdef BOOST_FOREACH_RUN_TIME_CONST_RVALUE_DETECTION
     831# ifdef BOOST_FOREACH_RUN_TIME_CONST_RVALUE_DETECTION
    714832template<typename T>
    715833inline auto_any<BOOST_DEDUCED_TYPENAME foreach_iterator<T, const_>::type>
    716834end(auto_any_t col, type2type<T, const_> *, bool *)
     
    718836    return auto_any<BOOST_DEDUCED_TYPENAME foreach_iterator<T, const_>::type>(
    719837        boost::end(*auto_any_cast<simple_variant<T>, boost::mpl::false_>(col).get()));
    720838}
    721 #endif
     839# endif
    722840
    723 #ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
     841# ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
    724842template<typename T, typename C>
    725843inline auto_any<int>
    726844end(auto_any_t, type2type<T *, C> *, boost::mpl::true_ *) // null-terminated C-style strings
    727845{
    728846    return auto_any<int>(0); // not used
    729847}
     848# endif
    730849#endif
    731850
    732851///////////////////////////////////////////////////////////////////////////////
    733852// done
    734853//
     854#if defined(BOOST_FOREACH_USE_CXX11)
     855template<typename Iterator, typename Col>
     856inline typename boost::disable_if<
     857    boost::is_pointer<Col>
     858  , bool
     859>::type
     860done(Iterator const &cur, Iterator const &end, Col &)
     861{
     862    return cur == end;
     863}
     864
     865template<typename Iterator, typename Col>
     866inline typename boost::enable_if<
     867    boost::is_pointer<Col>
     868  , bool
     869>::type
     870done(Iterator const &cur, Iterator const &end, Col &) // null-terminated C-style strings
     871{
     872    return *cur == 0;
     873}
     874
     875#elif defined(BOOST_FOREACH_USE_CXX11_GCC_WORKAROUND)
     876template<typename Col>
     877inline typename boost::disable_if<
     878    boost::is_pointer<Col>
     879  , bool
     880>::type
     881done(auto_any_t cur, auto_any_t end, Col &)
     882{
     883    typedef typename foreach_iterator_<Col>::type iterator;
     884    return auto_any_cast<iterator>(cur) == auto_any_cast<iterator>(end);
     885}
     886
     887template<typename Col>
     888inline typename boost::enable_if<
     889    boost::is_pointer<Col>
     890  , bool
     891>::type
     892done(auto_any_t cur, auto_any_t, Col &) // null-terminated C-style strings
     893{
     894    typedef typename foreach_iterator_<Col>::type iterator;
     895    return *auto_any_cast<iterator>(cur) == 0;
     896}
     897
     898#else
    735899template<typename T, typename C>
    736900inline bool done(auto_any_t cur, auto_any_t end, type2type<T, C> *)
    737901{
     
    739903    return auto_any_cast<iter_t, boost::mpl::false_>(cur) == auto_any_cast<iter_t, boost::mpl::false_>(end);
    740904}
    741905
    742 #ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
     906# ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
    743907template<typename T, typename C>
    744908inline bool done(auto_any_t cur, auto_any_t, type2type<T *, C> *) // null-terminated C-style strings
    745909{
    746910    return ! *auto_any_cast<T *, boost::mpl::false_>(cur);
    747911}
     912# endif
    748913#endif
    749914
    750915///////////////////////////////////////////////////////////////////////////////
    751916// next
    752917//
     918#if defined(BOOST_FOREACH_USE_CXX11)
     919template<typename Iterator, typename Col>
     920inline void next(Iterator &cur, Col &)
     921{
     922    ++cur;
     923}
     924
     925#elif defined(BOOST_FOREACH_USE_CXX11_GCC_WORKAROUND)
     926template<typename Col>
     927inline void next(auto_any_t cur, Col &)
     928{
     929    typedef typename foreach_iterator_<Col>::type iterator;
     930    ++auto_any_cast<iterator>(cur);
     931}
     932
     933#else
    753934template<typename T, typename C>
    754935inline void next(auto_any_t cur, type2type<T, C> *)
    755936{
    756937    typedef BOOST_DEDUCED_TYPENAME foreach_iterator<T, C>::type iter_t;
    757938    ++auto_any_cast<iter_t, boost::mpl::false_>(cur);
    758939}
     940#endif
    759941
    760942///////////////////////////////////////////////////////////////////////////////
    761943// deref
    762944//
     945#if defined(BOOST_FOREACH_USE_CXX11)
     946template<typename Iterator, typename Col>
     947inline typename foreach_reference_<Col>::type
     948deref(Iterator const &cur, Col &)
     949{
     950    return *cur;
     951}
     952
     953#elif defined(BOOST_FOREACH_USE_CXX11_GCC_WORKAROUND)
     954template<typename Col>
     955inline typename foreach_reference_<Col>::type
     956deref(auto_any_t cur, Col &)
     957{
     958    typedef typename foreach_iterator_<Col>::type iterator;
     959    return *auto_any_cast<iterator>(cur);
     960}
     961
     962#else
    763963template<typename T, typename C>
    764964inline BOOST_DEDUCED_TYPENAME foreach_reference<T, C>::type
    765965deref(auto_any_t cur, type2type<T, C> *)
     
    767967    typedef BOOST_DEDUCED_TYPENAME foreach_iterator<T, C>::type iter_t;
    768968    return *auto_any_cast<iter_t, boost::mpl::false_>(cur);
    769969}
     970#endif
    770971
    771972/////////////////////////////////////////////////////////////////////////////
    772973// rbegin
    773974//
     975#if defined(BOOST_FOREACH_USE_CXX11) || defined(BOOST_FOREACH_USE_CXX11_GCC_WORKAROUND)
     976template<typename T>
     977inline typename boost::disable_if<
     978    boost::is_pointer<T>
     979  , typename foreach_reverse_iterator_<T>::type
     980>::type
     981rbegin(T &col)
     982{
     983    return boost::rbegin(col);
     984}
     985
     986template<typename T>
     987inline typename boost::enable_if<
     988    boost::is_pointer<T>
     989  , typename foreach_reverse_iterator_<T>::type
     990>::type
     991rbegin(T &col) // null-terminated C-style strings
     992{
     993    typedef typename remove_const<T>::type pointer;
     994    pointer p = col;
     995    while(0 != *p)
     996        ++p;
     997    return typename foreach_reverse_iterator_<T>::type(p);
     998}
     999
     1000#else
    7741001template<typename T, typename C>
    7751002inline auto_any<BOOST_DEDUCED_TYPENAME foreach_reverse_iterator<T, C>::type>
    7761003rbegin(auto_any_t col, type2type<T, C> *, boost::mpl::true_ *) // rvalue
     
    7891016        iterator(boost::rbegin(derefof(auto_any_cast<type *, boost::mpl::false_>(col)))));
    7901017}
    7911018
    792 #ifdef BOOST_FOREACH_RUN_TIME_CONST_RVALUE_DETECTION
     1019# ifdef BOOST_FOREACH_RUN_TIME_CONST_RVALUE_DETECTION
    7931020template<typename T>
    7941021inline auto_any<BOOST_DEDUCED_TYPENAME foreach_reverse_iterator<T, const_>::type>
    7951022rbegin(auto_any_t col, type2type<T, const_> *, bool *)
     
    7971024    return auto_any<BOOST_DEDUCED_TYPENAME foreach_reverse_iterator<T, const_>::type>(
    7981025        boost::rbegin(*auto_any_cast<simple_variant<T>, boost::mpl::false_>(col).get()));
    7991026}
    800 #endif
     1027# endif
    8011028
    802 #ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
     1029# ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
    8031030template<typename T, typename C>
    8041031inline auto_any<reverse_iterator<T *> >
    8051032rbegin(auto_any_t col, type2type<T *, C> *, boost::mpl::true_ *) // null-terminated C-style strings
     
    8091036        ++p;
    8101037    return auto_any<reverse_iterator<T *> >(reverse_iterator<T *>(p));
    8111038}
     1039# endif
    8121040#endif
    8131041
    8141042///////////////////////////////////////////////////////////////////////////////
    8151043// rend
    8161044//
     1045#if defined(BOOST_FOREACH_USE_CXX11) || defined(BOOST_FOREACH_USE_CXX11_GCC_WORKAROUND)
     1046template<typename T>
     1047inline typename boost::disable_if<
     1048    boost::is_pointer<T>
     1049  , typename foreach_reverse_iterator_<T>::type
     1050>::type
     1051rend(T &col)
     1052{
     1053    return boost::rend(col);
     1054}
     1055
     1056template<typename T>
     1057inline typename boost::enable_if<
     1058    boost::is_pointer<T>
     1059  , typename foreach_reverse_iterator_<T>::type
     1060>::type
     1061rend(T &col) // null-terminated C-style strings
     1062{
     1063    return typename foreach_reverse_iterator_<T>::type(col);
     1064}
     1065
     1066#else
    8171067template<typename T, typename C>
    8181068inline auto_any<BOOST_DEDUCED_TYPENAME foreach_reverse_iterator<T, C>::type>
    8191069rend(auto_any_t col, type2type<T, C> *, boost::mpl::true_ *) // rvalue
     
    8321082        iterator(boost::rend(derefof(auto_any_cast<type *, boost::mpl::false_>(col)))));
    8331083}
    8341084
    835 #ifdef BOOST_FOREACH_RUN_TIME_CONST_RVALUE_DETECTION
     1085# ifdef BOOST_FOREACH_RUN_TIME_CONST_RVALUE_DETECTION
    8361086template<typename T>
    8371087inline auto_any<BOOST_DEDUCED_TYPENAME foreach_reverse_iterator<T, const_>::type>
    8381088rend(auto_any_t col, type2type<T, const_> *, bool *)
     
    8401090    return auto_any<BOOST_DEDUCED_TYPENAME foreach_reverse_iterator<T, const_>::type>(
    8411091        boost::rend(*auto_any_cast<simple_variant<T>, boost::mpl::false_>(col).get()));
    8421092}
    843 #endif
     1093# endif
    8441094
    845 #ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
     1095# ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
    8461096template<typename T, typename C>
    8471097inline auto_any<reverse_iterator<T *> >
    8481098rend(auto_any_t col, type2type<T *, C> *, boost::mpl::true_ *) // null-terminated C-style strings
     
    8501100    return auto_any<reverse_iterator<T *> >(
    8511101        reverse_iterator<T *>(auto_any_cast<T *, boost::mpl::false_>(col)));
    8521102}
     1103# endif
    8531104#endif
    8541105
    8551106///////////////////////////////////////////////////////////////////////////////
    8561107// rdone
    8571108//
     1109#if defined(BOOST_FOREACH_USE_CXX11)
     1110template<typename Iterator, typename Col>
     1111inline bool rdone(Iterator const &cur, Iterator const &end, Col &)
     1112{
     1113    return cur == end;
     1114}
     1115
     1116#elif defined(BOOST_FOREACH_USE_CXX11_GCC_WORKAROUND)
     1117template<typename Col>
     1118inline bool rdone(auto_any_t cur, auto_any_t end, Col &)
     1119{
     1120    typedef typename foreach_reverse_iterator_<Col>::type iterator;
     1121    return auto_any_cast<iterator>(cur) == auto_any_cast<iterator>(end);
     1122}
     1123
     1124#else
    8581125template<typename T, typename C>
    8591126inline bool rdone(auto_any_t cur, auto_any_t end, type2type<T, C> *)
    8601127{
    8611128    typedef BOOST_DEDUCED_TYPENAME foreach_reverse_iterator<T, C>::type iter_t;
    8621129    return auto_any_cast<iter_t, boost::mpl::false_>(cur) == auto_any_cast<iter_t, boost::mpl::false_>(end);
    8631130}
     1131#endif
    8641132
    8651133///////////////////////////////////////////////////////////////////////////////
    8661134// rnext
    8671135//
     1136#if defined(BOOST_FOREACH_USE_CXX11)
     1137template<typename Iterator, typename Col>
     1138inline void rnext(Iterator &cur, Col &)
     1139{
     1140    ++cur;
     1141}
     1142
     1143#elif defined(BOOST_FOREACH_USE_CXX11_GCC_WORKAROUND)
     1144template<typename Col>
     1145inline void rnext(auto_any_t cur, Col &)
     1146{
     1147    typedef typename foreach_reverse_iterator_<Col>::type iterator;
     1148    ++auto_any_cast<iterator>(cur);
     1149}
     1150
     1151#else
    8681152template<typename T, typename C>
    8691153inline void rnext(auto_any_t cur, type2type<T, C> *)
    8701154{
    8711155    typedef BOOST_DEDUCED_TYPENAME foreach_reverse_iterator<T, C>::type iter_t;
    8721156    ++auto_any_cast<iter_t, boost::mpl::false_>(cur);
    8731157}
     1158#endif
    8741159
    8751160///////////////////////////////////////////////////////////////////////////////
    8761161// rderef
    8771162//
     1163#if defined(BOOST_FOREACH_USE_CXX11)
     1164template<typename Iterator, typename Col>
     1165inline typename foreach_reference_<Col>::type
     1166rderef(Iterator const &cur, Col &)
     1167{
     1168    return *cur;
     1169}
     1170
     1171#elif defined(BOOST_FOREACH_USE_CXX11_GCC_WORKAROUND)
     1172template<typename Col>
     1173inline typename foreach_reference_<Col>::type
     1174rderef(auto_any_t cur, Col &)
     1175{
     1176    typedef typename foreach_reverse_iterator_<Col>::type iterator;
     1177    return *auto_any_cast<iterator>(cur);
     1178}
     1179
     1180#else
    8781181template<typename T, typename C>
    8791182inline BOOST_DEDUCED_TYPENAME foreach_reference<T, C>::type
    8801183rderef(auto_any_t cur, type2type<T, C> *)
     
    8821185    typedef BOOST_DEDUCED_TYPENAME foreach_reverse_iterator<T, C>::type iter_t;
    8831186    return *auto_any_cast<iter_t, boost::mpl::false_>(cur);
    8841187}
     1188#endif
    8851189
    8861190} // namespace foreach_detail_
    8871191} // namespace boost
     
    9041208# define BOOST_FOREACH_ID(x) BOOST_PP_CAT(x, __LINE__)
    9051209#endif
    9061210
     1211#if !defined(BOOST_FOREACH_USE_CXX11) && !defined(BOOST_FOREACH_USE_CXX11_GCC_WORKAROUND)
    9071212// A sneaky way to get the type of the collection without evaluating the expression
    908 #define BOOST_FOREACH_TYPEOF(COL)                                                               \
     1213# define BOOST_FOREACH_TYPEOF(COL)                                                              \
    9091214    (true ? 0 : boost::foreach_detail_::encode_type(COL, boost::foreach_detail_::is_const_(COL)))
    9101215
    9111216// returns true_* if the type is noncopyable
    912 #define BOOST_FOREACH_IS_NONCOPYABLE(COL)                                                       \
     1217# define BOOST_FOREACH_IS_NONCOPYABLE(COL)                                                      \
    9131218    boost_foreach_is_noncopyable(                                                               \
    9141219        boost::foreach_detail_::to_ptr(COL)                                                     \
    9151220      , boost_foreach_argument_dependent_lookup_hack_value)
    9161221
    9171222// returns true_* if the type is a lightweight proxy (and is not noncopyable)
    918 #define BOOST_FOREACH_IS_LIGHTWEIGHT_PROXY(COL)                                                 \
     1223# define BOOST_FOREACH_IS_LIGHTWEIGHT_PROXY(COL)                                                \
    9191224    boost::foreach_detail_::and_(                                                               \
    9201225        boost::foreach_detail_::not_(BOOST_FOREACH_IS_NONCOPYABLE(COL))                         \
    9211226      , boost_foreach_is_lightweight_proxy(                                                     \
    9221227            boost::foreach_detail_::to_ptr(COL)                                                 \
    9231228          , boost_foreach_argument_dependent_lookup_hack_value))
     1229#endif
    9241230
    925 #if defined(BOOST_FOREACH_COMPILE_TIME_CONST_RVALUE_DETECTION)
     1231#if defined(BOOST_FOREACH_USE_CXX11)
    9261232///////////////////////////////////////////////////////////////////////////////
     1233// R-values and const R-values are bound to rvalue references
     1234///////////////////////////////////////////////////////////////////////////////
     1235
     1236// No variable is needed to track the rvalue-ness of the collection expression
     1237# define BOOST_FOREACH_PREAMBLE()                                                               \
     1238    BOOST_FOREACH_SUPPRESS_WARNINGS()
     1239
     1240namespace boost { namespace foreach_detail_
     1241{
     1242    template<typename T>
     1243    inline boost::is_rvalue_reference<T &&> *is_rvalue(T &&) { return 0; }
     1244
     1245    template<typename T, typename Cond>
     1246    inline typename boost::mpl::if_<Cond, T const &, T &>::type
     1247    add_const_if(T &t, Cond *)
     1248    {
     1249        return t;
     1250    }
     1251}}
     1252
     1253# define BOOST_FOREACH_IS_RVALUE(COL) (true ? 0 : boost::foreach_detail_::is_rvalue(COL))
     1254
     1255// Non-const rvalue collections are accessed as const references.
     1256# define BOOST_FOREACH_REF(COL)                                                                 \
     1257    boost::foreach_detail_::add_const_if(                                                       \
     1258        BOOST_FOREACH_ID(_foreach_col)                                                          \
     1259      , BOOST_FOREACH_IS_RVALUE(COL))
     1260
     1261#elif defined(BOOST_FOREACH_USE_CXX11_GCC_WORKAROUND)
     1262///////////////////////////////////////////////////////////////////////////////
     1263// R-values and const R-values are bound to const lvalue references
     1264///////////////////////////////////////////////////////////////////////////////
     1265
     1266// No variable is needed to track the rvalue-ness of the collection expression
     1267# define BOOST_FOREACH_PREAMBLE()                                                               \
     1268    BOOST_FOREACH_SUPPRESS_WARNINGS()
     1269
     1270namespace boost { namespace foreach_detail_
     1271{
     1272    template<typename T>
     1273    inline boost::mpl::true_  *is_nonconst_lvalue(T&)       { return 0; }
     1274
     1275    template<typename T>
     1276    inline boost::mpl::false_ *is_nonconst_lvalue(T const&) { return 0; }
     1277
     1278    template<typename T, typename Cond>
     1279    inline typename boost::mpl::if_<Cond, typename boost::remove_const<T>::type &, T &>::type
     1280    remove_const_if(T &t, Cond *)
     1281    {
     1282        return const_cast<
     1283            typename boost::mpl::if_<Cond, typename boost::remove_const<T>::type &, T &>::type
     1284        >(t);
     1285    }
     1286}}
     1287
     1288# define BOOST_FOREACH_IS_NONCONST_LVALUE(COL) (true ? 0 : boost::foreach_detail_::is_nonconst_lvalue(COL))
     1289
     1290// Only non-const lvalue collections are accessed as non-const references.
     1291# define BOOST_FOREACH_REF(COL)                                                                 \
     1292    boost::foreach_detail_::remove_const_if(                                                    \
     1293        BOOST_FOREACH_ID(_foreach_col)                                                          \
     1294      , BOOST_FOREACH_IS_NONCONST_LVALUE(COL))
     1295
     1296#elif defined(BOOST_FOREACH_COMPILE_TIME_CONST_RVALUE_DETECTION)
     1297///////////////////////////////////////////////////////////////////////////////
    9271298// R-values and const R-values supported here with zero runtime overhead
    9281299///////////////////////////////////////////////////////////////////////////////
    9291300
     
    10051376
    10061377#endif
    10071378
    1008 #define BOOST_FOREACH_CONTAIN(COL)                                                              \
     1379#if defined(BOOST_FOREACH_USE_CXX11)
     1380# define BOOST_FOREACH_BEGIN(COL)                                                               \
     1381    boost::foreach_detail_::begin(                                                              \
     1382        BOOST_FOREACH_REF(COL))
     1383
     1384# define BOOST_FOREACH_END(COL)                                                                 \
     1385    boost::foreach_detail_::end(                                                                \
     1386        BOOST_FOREACH_REF(COL))
     1387
     1388# define BOOST_FOREACH_DONE(COL)                                                                \
     1389    boost::foreach_detail_::done(                                                               \
     1390        BOOST_FOREACH_ID(_foreach_cur)                                                          \
     1391      , BOOST_FOREACH_ID(_foreach_end)                                                          \
     1392      , BOOST_FOREACH_REF(COL))
     1393
     1394# define BOOST_FOREACH_NEXT(COL)                                                                \
     1395    boost::foreach_detail_::next(                                                               \
     1396        BOOST_FOREACH_ID(_foreach_cur)                                                          \
     1397      , BOOST_FOREACH_REF(COL))
     1398
     1399# define BOOST_FOREACH_DEREF(COL)                                                               \
     1400    boost::foreach_detail_::deref(                                                              \
     1401        BOOST_FOREACH_ID(_foreach_cur)                                                          \
     1402      , BOOST_FOREACH_REF(COL))
     1403
     1404# define BOOST_FOREACH_RBEGIN(COL)                                                              \
     1405    boost::foreach_detail_::rbegin(                                                             \
     1406        BOOST_FOREACH_REF(COL))
     1407
     1408# define BOOST_FOREACH_REND(COL)                                                                \
     1409    boost::foreach_detail_::rend(                                                               \
     1410        BOOST_FOREACH_REF(COL))
     1411
     1412# define BOOST_FOREACH_RDONE(COL)                                                               \
     1413    boost::foreach_detail_::rdone(                                                              \
     1414        BOOST_FOREACH_ID(_foreach_cur)                                                          \
     1415      , BOOST_FOREACH_ID(_foreach_end)                                                          \
     1416      , BOOST_FOREACH_REF(COL))
     1417
     1418# define BOOST_FOREACH_RNEXT(COL)                                                               \
     1419    boost::foreach_detail_::rnext(                                                              \
     1420        BOOST_FOREACH_ID(_foreach_cur)                                                          \
     1421      , BOOST_FOREACH_REF(COL))
     1422
     1423# define BOOST_FOREACH_RDEREF(COL)                                                              \
     1424    boost::foreach_detail_::rderef(                                                             \
     1425        BOOST_FOREACH_ID(_foreach_cur)                                                          \
     1426      , BOOST_FOREACH_REF(COL))
     1427
     1428#elif defined(BOOST_FOREACH_USE_CXX11_GCC_WORKAROUND)
     1429# define BOOST_FOREACH_BEGIN(COL)                                                               \
     1430    boost::foreach_detail_::make_auto_any(                                                      \
     1431        boost::foreach_detail_::begin(                                                          \
     1432            BOOST_FOREACH_REF(COL)))
     1433
     1434# define BOOST_FOREACH_END(COL)                                                                 \
     1435    boost::foreach_detail_::make_auto_any(                                                      \
     1436        boost::foreach_detail_::end(                                                            \
     1437            BOOST_FOREACH_REF(COL)))
     1438
     1439# define BOOST_FOREACH_DONE(COL)                                                                \
     1440    boost::foreach_detail_::done(                                                               \
     1441        BOOST_FOREACH_ID(_foreach_cur)                                                          \
     1442      , BOOST_FOREACH_ID(_foreach_end)                                                          \
     1443      , BOOST_FOREACH_REF(COL))
     1444
     1445# define BOOST_FOREACH_NEXT(COL)                                                                \
     1446    boost::foreach_detail_::next(                                                               \
     1447        BOOST_FOREACH_ID(_foreach_cur)                                                          \
     1448      , BOOST_FOREACH_REF(COL))
     1449
     1450# define BOOST_FOREACH_DEREF(COL)                                                               \
     1451    boost::foreach_detail_::deref(                                                              \
     1452        BOOST_FOREACH_ID(_foreach_cur)                                                          \
     1453      , BOOST_FOREACH_REF(COL))
     1454
     1455# define BOOST_FOREACH_RBEGIN(COL)                                                              \
     1456    boost::foreach_detail_::make_auto_any(                                                      \
     1457        boost::foreach_detail_::rbegin(                                                         \
     1458            BOOST_FOREACH_REF(COL)))
     1459
     1460# define BOOST_FOREACH_REND(COL)                                                                \
     1461    boost::foreach_detail_::make_auto_any(                                                      \
     1462        boost::foreach_detail_::rend(                                                           \
     1463            BOOST_FOREACH_REF(COL)))
     1464
     1465# define BOOST_FOREACH_RDONE(COL)                                                               \
     1466    boost::foreach_detail_::rdone(                                                              \
     1467        BOOST_FOREACH_ID(_foreach_cur)                                                          \
     1468      , BOOST_FOREACH_ID(_foreach_end)                                                          \
     1469      , BOOST_FOREACH_REF(COL))
     1470
     1471# define BOOST_FOREACH_RNEXT(COL)                                                               \
     1472    boost::foreach_detail_::rnext(                                                              \
     1473        BOOST_FOREACH_ID(_foreach_cur)                                                          \
     1474      , BOOST_FOREACH_REF(COL))
     1475
     1476# define BOOST_FOREACH_RDEREF(COL)                                                              \
     1477    boost::foreach_detail_::rderef(                                                             \
     1478        BOOST_FOREACH_ID(_foreach_cur)                                                          \
     1479      , BOOST_FOREACH_REF(COL))
     1480
     1481#else
     1482# define BOOST_FOREACH_CONTAIN(COL)                                                             \
    10091483    boost::foreach_detail_::contain(                                                            \
    10101484        BOOST_FOREACH_EVALUATE(COL)                                                             \
    10111485      , BOOST_FOREACH_SHOULD_COPY(COL))
    10121486
    1013 #define BOOST_FOREACH_BEGIN(COL)                                                                \
     1487# define BOOST_FOREACH_BEGIN(COL)                                                               \
    10141488    boost::foreach_detail_::begin(                                                              \
    10151489        BOOST_FOREACH_ID(_foreach_col)                                                          \
    10161490      , BOOST_FOREACH_TYPEOF(COL)                                                               \
    10171491      , BOOST_FOREACH_SHOULD_COPY(COL))
    10181492
    1019 #define BOOST_FOREACH_END(COL)                                                                  \
     1493# define BOOST_FOREACH_END(COL)                                                                 \
    10201494    boost::foreach_detail_::end(                                                                \
    10211495        BOOST_FOREACH_ID(_foreach_col)                                                          \
    10221496      , BOOST_FOREACH_TYPEOF(COL)                                                               \
    10231497      , BOOST_FOREACH_SHOULD_COPY(COL))
    10241498
    1025 #define BOOST_FOREACH_DONE(COL)                                                                 \
     1499# define BOOST_FOREACH_DONE(COL)                                                                \
    10261500    boost::foreach_detail_::done(                                                               \
    10271501        BOOST_FOREACH_ID(_foreach_cur)                                                          \
    10281502      , BOOST_FOREACH_ID(_foreach_end)                                                          \
    10291503      , BOOST_FOREACH_TYPEOF(COL))
    10301504
    1031 #define BOOST_FOREACH_NEXT(COL)                                                                 \
     1505# define BOOST_FOREACH_NEXT(COL)                                                                \
    10321506    boost::foreach_detail_::next(                                                               \
    10331507        BOOST_FOREACH_ID(_foreach_cur)                                                          \
    10341508      , BOOST_FOREACH_TYPEOF(COL))
    10351509
    1036 #define BOOST_FOREACH_DEREF(COL)                                                                \
     1510# define BOOST_FOREACH_DEREF(COL)                                                               \
    10371511    boost::foreach_detail_::deref(                                                              \
    10381512        BOOST_FOREACH_ID(_foreach_cur)                                                          \
    10391513      , BOOST_FOREACH_TYPEOF(COL))
    10401514
    1041 #define BOOST_FOREACH_RBEGIN(COL)                                                               \
     1515# define BOOST_FOREACH_RBEGIN(COL)                                                              \
    10421516    boost::foreach_detail_::rbegin(                                                             \
    10431517        BOOST_FOREACH_ID(_foreach_col)                                                          \
    10441518      , BOOST_FOREACH_TYPEOF(COL)                                                               \
    10451519      , BOOST_FOREACH_SHOULD_COPY(COL))
    10461520
    1047 #define BOOST_FOREACH_REND(COL)                                                                 \
     1521# define BOOST_FOREACH_REND(COL)                                                                \
    10481522    boost::foreach_detail_::rend(                                                               \
    10491523        BOOST_FOREACH_ID(_foreach_col)                                                          \
    10501524      , BOOST_FOREACH_TYPEOF(COL)                                                               \
    10511525      , BOOST_FOREACH_SHOULD_COPY(COL))
    10521526
    1053 #define BOOST_FOREACH_RDONE(COL)                                                                \
     1527# define BOOST_FOREACH_RDONE(COL)                                                               \
    10541528    boost::foreach_detail_::rdone(                                                              \
    10551529        BOOST_FOREACH_ID(_foreach_cur)                                                          \
    10561530      , BOOST_FOREACH_ID(_foreach_end)                                                          \
    10571531      , BOOST_FOREACH_TYPEOF(COL))
    10581532
    1059 #define BOOST_FOREACH_RNEXT(COL)                                                                \
     1533# define BOOST_FOREACH_RNEXT(COL)                                                               \
    10601534    boost::foreach_detail_::rnext(                                                              \
    10611535        BOOST_FOREACH_ID(_foreach_cur)                                                          \
    10621536      , BOOST_FOREACH_TYPEOF(COL))
    10631537
    1064 #define BOOST_FOREACH_RDEREF(COL)                                                               \
     1538# define BOOST_FOREACH_RDEREF(COL)                                                              \
    10651539    boost::foreach_detail_::rderef(                                                             \
    10661540        BOOST_FOREACH_ID(_foreach_cur)                                                          \
    10671541      , BOOST_FOREACH_TYPEOF(COL))
    10681542
     1543#endif
     1544
    10691545///////////////////////////////////////////////////////////////////////////////
    10701546// BOOST_FOREACH
    10711547//
     
    10921568//   BOOST_FOREACH(i, int_list)
    10931569//       { ... }
    10941570//
    1095 #define BOOST_FOREACH(VAR, COL)                                                                                   \
     1571#if defined(BOOST_FOREACH_USE_CXX11)
     1572# define BOOST_FOREACH(VAR, COL)                                                                                  \
    10961573    BOOST_FOREACH_PREAMBLE()                                                                                      \
     1574    if (bool BOOST_FOREACH_ID(_foreach_col_defined) = false) {} else                                              \
     1575    for (auto &&BOOST_FOREACH_ID(_foreach_col) = (COL);                                                           \
     1576        !BOOST_FOREACH_ID(_foreach_col_defined); BOOST_FOREACH_ID(_foreach_col_defined) = true)                   \
     1577    if (bool BOOST_FOREACH_ID(_foreach_cur_defined) = false) {} else                                              \
     1578    for (auto BOOST_FOREACH_ID(_foreach_cur) = BOOST_FOREACH_BEGIN(COL);                                          \
     1579        !BOOST_FOREACH_ID(_foreach_cur_defined); BOOST_FOREACH_ID(_foreach_cur_defined) = true)                   \
     1580    if (bool BOOST_FOREACH_ID(_foreach_end_defined) = false) {} else                                              \
     1581    for (auto BOOST_FOREACH_ID(_foreach_end) = BOOST_FOREACH_END(COL);                                            \
     1582        !BOOST_FOREACH_ID(_foreach_end_defined); BOOST_FOREACH_ID(_foreach_end_defined) = true)                   \
     1583    for (bool BOOST_FOREACH_ID(_foreach_continue) = true;                                                         \
     1584              BOOST_FOREACH_ID(_foreach_continue) && !BOOST_FOREACH_DONE(COL);                                    \
     1585              BOOST_FOREACH_ID(_foreach_continue) ? BOOST_FOREACH_NEXT(COL) : (void)0)                            \
     1586        if ( (BOOST_FOREACH_ID(_foreach_continue) = false) ) {} else                                              \
     1587        for (VAR = BOOST_FOREACH_DEREF(COL); !BOOST_FOREACH_ID(_foreach_continue); BOOST_FOREACH_ID(_foreach_continue) = true)
     1588
     1589#elif defined(BOOST_FOREACH_USE_CXX11_GCC_WORKAROUND)
     1590# define BOOST_FOREACH(VAR, COL)                                                                                  \
     1591    BOOST_FOREACH_PREAMBLE()                                                                                      \
     1592    if (bool BOOST_FOREACH_ID(_foreach_col_defined) = false) {} else                                              \
     1593    for (auto const &BOOST_FOREACH_ID(_foreach_col) = (COL);                                                      \
     1594        !BOOST_FOREACH_ID(_foreach_col_defined); BOOST_FOREACH_ID(_foreach_col_defined) = true)                   \
     1595    if (boost::foreach_detail_::auto_any_t BOOST_FOREACH_ID(_foreach_cur) = BOOST_FOREACH_BEGIN(COL)) {} else     \
     1596    if (boost::foreach_detail_::auto_any_t BOOST_FOREACH_ID(_foreach_end) = BOOST_FOREACH_END(COL)) {} else       \
     1597    for (bool BOOST_FOREACH_ID(_foreach_continue) = true;                                                         \
     1598              BOOST_FOREACH_ID(_foreach_continue) && !BOOST_FOREACH_DONE(COL);                                    \
     1599              BOOST_FOREACH_ID(_foreach_continue) ? BOOST_FOREACH_NEXT(COL) : (void)0)                            \
     1600        if ( (BOOST_FOREACH_ID(_foreach_continue) = false) ) {} else                                              \
     1601        for (VAR = BOOST_FOREACH_DEREF(COL); !BOOST_FOREACH_ID(_foreach_continue); BOOST_FOREACH_ID(_foreach_continue) = true)
     1602
     1603#else
     1604# define BOOST_FOREACH(VAR, COL)                                                                                  \
     1605    BOOST_FOREACH_PREAMBLE()                                                                                      \
    10971606    if (boost::foreach_detail_::auto_any_t BOOST_FOREACH_ID(_foreach_col) = BOOST_FOREACH_CONTAIN(COL)) {} else   \
    10981607    if (boost::foreach_detail_::auto_any_t BOOST_FOREACH_ID(_foreach_cur) = BOOST_FOREACH_BEGIN(COL)) {} else     \
    10991608    if (boost::foreach_detail_::auto_any_t BOOST_FOREACH_ID(_foreach_end) = BOOST_FOREACH_END(COL)) {} else       \
     
    11031612        if  (boost::foreach_detail_::set_false(BOOST_FOREACH_ID(_foreach_continue))) {} else                      \
    11041613        for (VAR = BOOST_FOREACH_DEREF(COL); !BOOST_FOREACH_ID(_foreach_continue); BOOST_FOREACH_ID(_foreach_continue) = true)
    11051614
     1615#endif
     1616
    11061617///////////////////////////////////////////////////////////////////////////////
    11071618// BOOST_REVERSE_FOREACH
    11081619//
     
    11101621//   all other respects, BOOST_REVERSE_FOREACH is like
    11111622//   BOOST_FOREACH.
    11121623//
    1113 #define BOOST_REVERSE_FOREACH(VAR, COL)                                                                           \
     1624#if defined(BOOST_FOREACH_USE_CXX11)
     1625# define BOOST_REVERSE_FOREACH(VAR, COL)                                                                          \
    11141626    BOOST_FOREACH_PREAMBLE()                                                                                      \
     1627    if (bool BOOST_FOREACH_ID(_foreach_col_defined) = false) {} else                                              \
     1628    for (auto &&BOOST_FOREACH_ID(_foreach_col) = (COL);                                                           \
     1629        !BOOST_FOREACH_ID(_foreach_col_defined); BOOST_FOREACH_ID(_foreach_col_defined) = true)                   \
     1630                                                                                                                  \
     1631    if (bool BOOST_FOREACH_ID(_foreach_cur_defined) = false) {} else                                              \
     1632    for (auto BOOST_FOREACH_ID(_foreach_cur) = BOOST_FOREACH_RBEGIN(COL);                                         \
     1633        !BOOST_FOREACH_ID(_foreach_cur_defined); BOOST_FOREACH_ID(_foreach_cur_defined) = true)                   \
     1634                                                                                                                  \
     1635    if (bool BOOST_FOREACH_ID(_foreach_end_defined) = false) {} else                                              \
     1636    for (auto BOOST_FOREACH_ID(_foreach_end) = BOOST_FOREACH_REND(COL);                                           \
     1637        !BOOST_FOREACH_ID(_foreach_end_defined); BOOST_FOREACH_ID(_foreach_end_defined) = true)                   \
     1638                                                                                                                  \
     1639    for (bool BOOST_FOREACH_ID(_foreach_continue) = true;                                                         \
     1640              BOOST_FOREACH_ID(_foreach_continue) && !BOOST_FOREACH_RDONE(COL);                                   \
     1641              BOOST_FOREACH_ID(_foreach_continue) ? BOOST_FOREACH_RNEXT(COL) : (void)0)                           \
     1642        if ( (BOOST_FOREACH_ID(_foreach_continue) = false) ) {} else                                              \
     1643        for (VAR = BOOST_FOREACH_RDEREF(COL); !BOOST_FOREACH_ID(_foreach_continue); BOOST_FOREACH_ID(_foreach_continue) = true)
     1644
     1645#elif defined(BOOST_FOREACH_USE_CXX11_GCC_WORKAROUND)
     1646# define BOOST_REVERSE_FOREACH(VAR, COL)                                                                          \
     1647    BOOST_FOREACH_PREAMBLE()                                                                                      \
     1648    if (bool BOOST_FOREACH_ID(_foreach_col_defined) = false) {} else                                              \
     1649    for (auto const &BOOST_FOREACH_ID(_foreach_col) = (COL);                                                      \
     1650        !BOOST_FOREACH_ID(_foreach_col_defined); BOOST_FOREACH_ID(_foreach_col_defined) = true)                   \
     1651    if (boost::foreach_detail_::auto_any_t BOOST_FOREACH_ID(_foreach_cur) = BOOST_FOREACH_RBEGIN(COL)) {} else    \
     1652    if (boost::foreach_detail_::auto_any_t BOOST_FOREACH_ID(_foreach_end) = BOOST_FOREACH_REND(COL)) {} else      \
     1653    for (bool BOOST_FOREACH_ID(_foreach_continue) = true;                                                         \
     1654              BOOST_FOREACH_ID(_foreach_continue) && !BOOST_FOREACH_RDONE(COL);                                   \
     1655              BOOST_FOREACH_ID(_foreach_continue) ? BOOST_FOREACH_RNEXT(COL) : (void)0)                           \
     1656        if ( (BOOST_FOREACH_ID(_foreach_continue) = false) ) {} else                                              \
     1657        for (VAR = BOOST_FOREACH_RDEREF(COL); !BOOST_FOREACH_ID(_foreach_continue); BOOST_FOREACH_ID(_foreach_continue) = true)
     1658
     1659#else
     1660# define BOOST_REVERSE_FOREACH(VAR, COL)                                                                          \
     1661    BOOST_FOREACH_PREAMBLE()                                                                                      \
    11151662    if (boost::foreach_detail_::auto_any_t BOOST_FOREACH_ID(_foreach_col) = BOOST_FOREACH_CONTAIN(COL)) {} else   \
    11161663    if (boost::foreach_detail_::auto_any_t BOOST_FOREACH_ID(_foreach_cur) = BOOST_FOREACH_RBEGIN(COL)) {} else    \
    11171664    if (boost::foreach_detail_::auto_any_t BOOST_FOREACH_ID(_foreach_end) = BOOST_FOREACH_REND(COL)) {} else      \
     
    11221669        for (VAR = BOOST_FOREACH_RDEREF(COL); !BOOST_FOREACH_ID(_foreach_continue); BOOST_FOREACH_ID(_foreach_continue) = true)
    11231670
    11241671#endif
     1672
     1673#endif