Ticket #5475: foreach_use_cxx11.patch
File foreach_use_cxx11.patch, 48.7 KB (added by , 11 years ago) |
---|
-
boost/foreach.hpp
30 30 #include <boost/config.hpp> 31 31 #include <boost/detail/workaround.hpp> 32 32 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 33 47 // 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) \ 35 49 || BOOST_WORKAROUND(BOOST_MSVC, >= 1310) && !defined(_PREFAST_) \ 36 50 || (BOOST_WORKAROUND(__GNUC__, == 4) && (__GNUC_MINOR__ <= 5) && !defined(BOOST_INTEL) && \ 37 51 !defined(BOOST_CLANG)) \ … … 88 102 #include <boost/utility/addressof.hpp> 89 103 #include <boost/foreach_fwd.hpp> 90 104 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 91 110 #ifdef BOOST_FOREACH_RUN_TIME_CONST_RVALUE_DETECTION 92 111 # include <new> 93 112 # include <boost/aligned_storage.hpp> … … 95 114 # include <boost/type_traits/remove_const.hpp> 96 115 #endif 97 116 117 #if !defined(BOOST_FOREACH_USE_CXX11) && !defined(BOOST_FOREACH_USE_CXX11_GCC_WORKAROUND) 98 118 namespace boost 99 119 { 100 120 … … 153 173 } // namespace boost 154 174 155 175 // vc6/7 needs help ordering the following overloads 156 # ifdef BOOST_NO_FUNCTION_TEMPLATE_ORDERING157 # define BOOST_FOREACH_TAG_DEFAULT ...158 # else159 # define BOOST_FOREACH_TAG_DEFAULT boost::foreach::tag160 # endif176 # 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 161 181 162 182 /////////////////////////////////////////////////////////////////////////////// 163 183 // boost_foreach_is_lightweight_proxy … … 192 212 template<typename T> 193 213 inline boost::foreach::is_noncopyable<T> * 194 214 boost_foreach_is_noncopyable(T *&, BOOST_FOREACH_TAG_DEFAULT) { return 0; } 215 #endif 195 216 196 217 namespace boost 197 218 { … … 199 220 namespace foreach_detail_ 200 221 { 201 222 223 #if !defined(BOOST_FOREACH_USE_CXX11) && !defined(BOOST_FOREACH_USE_CXX11_GCC_WORKAROUND) 202 224 /////////////////////////////////////////////////////////////////////////////// 203 225 // Define some utilities for assessing the properties of expressions 204 226 // … … 223 245 template<typename T> 224 246 inline boost::is_const<T> *is_const_(T &) { return 0; } 225 247 226 # ifndef BOOST_FOREACH_NO_RVALUE_DETECTION248 # ifndef BOOST_FOREACH_NO_RVALUE_DETECTION 227 249 template<typename T> 228 250 inline boost::mpl::true_ *is_const_(T const &) { return 0; } 229 # endif251 # endif 230 252 231 # ifdef BOOST_NO_RVALUE_REFERENCES253 # ifdef BOOST_NO_RVALUE_REFERENCES 232 254 template<typename T> 233 255 inline boost::mpl::false_ *is_rvalue_(T &, int) { return 0; } 234 256 235 257 template<typename T> 236 258 inline boost::mpl::true_ *is_rvalue_(T const &, ...) { return 0; } 237 # else259 # else 238 260 template<typename T> 239 261 inline boost::is_rvalue_reference<T &&> *is_rvalue_(T &&, int) { return 0; } 262 # endif 240 263 #endif 241 264 265 #if !defined(BOOST_FOREACH_USE_CXX11) 242 266 /////////////////////////////////////////////////////////////////////////////// 243 267 // auto_any_t/auto_any 244 268 // General utility for putting an object of any type into automatic storage … … 268 292 269 293 typedef auto_any_base const &auto_any_t; 270 294 295 # if defined(BOOST_FOREACH_USE_CXX11_GCC_WORKAROUND) 296 template<typename T> 297 inline T &auto_any_cast(auto_any_t a) 298 { 299 return static_cast<auto_any<T> const &>(a).item; 300 } 301 # else 271 302 template<typename T, typename C> 272 303 inline BOOST_DEDUCED_TYPENAME boost::mpl::if_<C, T const, T>::type &auto_any_cast(auto_any_t a) 273 304 { 274 305 return static_cast<auto_any<T> const &>(a).item; 275 306 } 307 # endif 276 308 309 # if defined(BOOST_FOREACH_USE_CXX11_GCC_WORKAROUND) 310 template<typename T> 311 inline 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) 277 319 typedef boost::mpl::true_ const_; 278 320 279 321 /////////////////////////////////////////////////////////////////////////////// … … 284 326 : boost::mpl::if_<C, T const, T> 285 327 { 286 328 }; 329 #endif 287 330 288 331 template<typename T> 289 332 struct wrap_cstr … … 364 407 >::type type; 365 408 }; 366 409 410 #if defined(BOOST_FOREACH_USE_CXX11) || defined(BOOST_FOREACH_USE_CXX11_GCC_WORKAROUND) 411 // just a shortcut for foreach_iterator<..., ...> 412 template<typename T> 413 struct range_iterator 414 : foreach_iterator<typename boost::remove_const<T>::type, boost::is_const<T> > 415 { 416 }; 417 #endif 367 418 368 419 template<typename T, typename C = boost::mpl::false_> 369 420 struct foreach_reverse_iterator … … 395 446 >::type type; 396 447 }; 397 448 449 #if defined(BOOST_FOREACH_USE_CXX11) || defined(BOOST_FOREACH_USE_CXX11_GCC_WORKAROUND) 450 // just a shortcut for foreach_reverse_iterator<..., ...> 451 template<typename T> 452 struct range_reverse_iterator 453 : foreach_reverse_iterator<typename boost::remove_const<T>::type, boost::is_const<T> > 454 { 455 }; 456 #endif 457 398 458 template<typename T, typename C = boost::mpl::false_> 399 459 struct foreach_reference 400 460 : iterator_reference<BOOST_DEDUCED_TYPENAME foreach_iterator<T, C>::type> 401 461 { 402 462 }; 403 463 464 #if defined(BOOST_FOREACH_USE_CXX11) || defined(BOOST_FOREACH_USE_CXX11_GCC_WORKAROUND) 465 // just a shortcut for foreach_reference<..., ...> 466 template<typename T> 467 struct range_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) 404 474 /////////////////////////////////////////////////////////////////////////////// 405 475 // encode_type 406 476 // … … 430 500 } 431 501 432 502 // 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)) 434 504 template<typename T,std::size_t N> 435 505 inline T (*&to_ptr(T (&)[N]))[N] 436 506 { 437 507 static T (*t)[N] = 0; 438 508 return t; 439 509 } 440 # endif510 # endif 441 511 442 512 /////////////////////////////////////////////////////////////////////////////// 443 513 // derefof … … 454 524 ); 455 525 } 456 526 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) 459 529 /////////////////////////////////////////////////////////////////////////////// 460 530 // Rvalue references makes it drop-dead simple to detect at compile time 461 531 // whether an expression is an rvalue. 462 532 /////////////////////////////////////////////////////////////////////////////// 463 533 464 # define BOOST_FOREACH_IS_RVALUE(COL)\534 # define BOOST_FOREACH_IS_RVALUE(COL) \ 465 535 boost::foreach_detail_::is_rvalue_((COL), 0) 466 536 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) 469 539 /////////////////////////////////////////////////////////////////////////////// 470 540 // Detect at compile-time whether an expression yields an rvalue or 471 541 // an lvalue. This is rather non-standard, but some popular compilers … … 493 563 return rvalue_probe<T>(); 494 564 } 495 565 496 # define BOOST_FOREACH_IS_RVALUE(COL)\566 # define BOOST_FOREACH_IS_RVALUE(COL) \ 497 567 boost::foreach_detail_::and_( \ 498 568 boost::foreach_detail_::not_(boost::foreach_detail_::is_array_(COL)) \ 499 569 , (true ? 0 : boost::foreach_detail_::is_rvalue_( \ 500 570 (true ? boost::foreach_detail_::make_probe(COL) : (COL)), 0))) 501 571 502 # elif defined(BOOST_FOREACH_RUN_TIME_CONST_RVALUE_DETECTION)572 # elif defined(BOOST_FOREACH_RUN_TIME_CONST_RVALUE_DETECTION) 503 573 /////////////////////////////////////////////////////////////////////////////// 504 574 // Detect at run-time whether an expression yields an rvalue 505 575 // or an lvalue. This is 100% standard C++, but not all compilers … … 618 688 return is_rvalue; 619 689 } 620 690 691 # endif 621 692 #endif 622 693 623 694 /////////////////////////////////////////////////////////////////////////////// 624 695 // contain 625 696 // 697 #if !defined(BOOST_FOREACH_USE_CXX11) && !defined(BOOST_FOREACH_USE_CXX11_GCC_WORKAROUND) 626 698 template<typename T> 627 699 inline auto_any<T> contain(T const &t, boost::mpl::true_ *) // rvalue 628 700 { … … 640 712 #endif 641 713 } 642 714 643 # ifdef BOOST_FOREACH_RUN_TIME_CONST_RVALUE_DETECTION715 # ifdef BOOST_FOREACH_RUN_TIME_CONST_RVALUE_DETECTION 644 716 template<typename T> 645 717 inline auto_any<simple_variant<T> > 646 718 contain(T const &t, bool *rvalue) 647 719 { 648 720 return auto_any<simple_variant<T> >(*rvalue ? simple_variant<T>(t) : simple_variant<T>(&t)); 649 721 } 722 # endif 650 723 #endif 651 724 652 725 ///////////////////////////////////////////////////////////////////////////// 653 726 // begin 654 727 // 728 #if defined(BOOST_FOREACH_USE_CXX11) || defined(BOOST_FOREACH_USE_CXX11_GCC_WORKAROUND) 729 template<typename T> 730 inline typename boost::disable_if< 731 boost::is_pointer<T> 732 , typename range_iterator<T>::type 733 >::type 734 begin(T &col) 735 { 736 return boost::begin(col); 737 } 738 739 template<typename T> 740 inline typename boost::enable_if< 741 boost::is_pointer<T> 742 , typename range_iterator<T>::type 743 >::type 744 begin(T &col) // null-terminated C-style strings 745 { 746 return col; 747 } 748 749 #else 655 750 template<typename T, typename C> 656 751 inline auto_any<BOOST_DEDUCED_TYPENAME foreach_iterator<T, C>::type> 657 752 begin(auto_any_t col, type2type<T, C> *, boost::mpl::true_ *) // rvalue … … 670 765 iterator(boost::begin(derefof(auto_any_cast<type *, boost::mpl::false_>(col))))); 671 766 } 672 767 673 # ifdef BOOST_FOREACH_RUN_TIME_CONST_RVALUE_DETECTION768 # ifdef BOOST_FOREACH_RUN_TIME_CONST_RVALUE_DETECTION 674 769 template<typename T> 675 770 inline auto_any<BOOST_DEDUCED_TYPENAME foreach_iterator<T, const_>::type> 676 771 begin(auto_any_t col, type2type<T, const_> *, bool *) … … 678 773 return auto_any<BOOST_DEDUCED_TYPENAME foreach_iterator<T, const_>::type>( 679 774 boost::begin(*auto_any_cast<simple_variant<T>, boost::mpl::false_>(col).get())); 680 775 } 681 # endif776 # endif 682 777 683 # ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING778 # ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING 684 779 template<typename T, typename C> 685 780 inline auto_any<T *> 686 781 begin(auto_any_t col, type2type<T *, C> *, boost::mpl::true_ *) // null-terminated C-style strings 687 782 { 688 783 return auto_any<T *>(auto_any_cast<T *, boost::mpl::false_>(col)); 689 784 } 785 # endif 690 786 #endif 691 787 692 788 /////////////////////////////////////////////////////////////////////////////// 693 789 // end 694 790 // 791 #if defined(BOOST_FOREACH_USE_CXX11) || defined(BOOST_FOREACH_USE_CXX11_GCC_WORKAROUND) 792 template<typename T> 793 inline typename boost::disable_if< 794 boost::is_pointer<T> 795 , typename range_iterator<T>::type 796 >::type 797 end(T &col) 798 { 799 return boost::end(col); 800 } 801 802 template<typename T> 803 inline typename boost::enable_if< 804 boost::is_pointer<T> 805 , typename range_iterator<T>::type 806 >::type 807 end(T &col) 808 { 809 return 0; 810 } 811 812 #else 695 813 template<typename T, typename C> 696 814 inline auto_any<BOOST_DEDUCED_TYPENAME foreach_iterator<T, C>::type> 697 815 end(auto_any_t col, type2type<T, C> *, boost::mpl::true_ *) // rvalue … … 710 828 iterator(boost::end(derefof(auto_any_cast<type *, boost::mpl::false_>(col))))); 711 829 } 712 830 713 # ifdef BOOST_FOREACH_RUN_TIME_CONST_RVALUE_DETECTION831 # ifdef BOOST_FOREACH_RUN_TIME_CONST_RVALUE_DETECTION 714 832 template<typename T> 715 833 inline auto_any<BOOST_DEDUCED_TYPENAME foreach_iterator<T, const_>::type> 716 834 end(auto_any_t col, type2type<T, const_> *, bool *) … … 718 836 return auto_any<BOOST_DEDUCED_TYPENAME foreach_iterator<T, const_>::type>( 719 837 boost::end(*auto_any_cast<simple_variant<T>, boost::mpl::false_>(col).get())); 720 838 } 721 # endif839 # endif 722 840 723 # ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING841 # ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING 724 842 template<typename T, typename C> 725 843 inline auto_any<int> 726 844 end(auto_any_t, type2type<T *, C> *, boost::mpl::true_ *) // null-terminated C-style strings 727 845 { 728 846 return auto_any<int>(0); // not used 729 847 } 848 # endif 730 849 #endif 731 850 732 851 /////////////////////////////////////////////////////////////////////////////// 733 852 // done 734 853 // 854 #if defined(BOOST_FOREACH_USE_CXX11) 855 template<typename Iterator, typename Col> 856 inline typename boost::disable_if< 857 boost::is_pointer<Col> 858 , bool 859 >::type 860 done(Iterator const &cur, Iterator const &end, Col &) 861 { 862 return cur == end; 863 } 864 865 template<typename Iterator, typename Col> 866 inline typename boost::enable_if< 867 boost::is_pointer<Col> 868 , bool 869 >::type 870 done(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) 876 template<typename Col> 877 inline typename boost::disable_if< 878 boost::is_pointer<Col> 879 , bool 880 >::type 881 done(auto_any_t cur, auto_any_t end, Col &) 882 { 883 typedef typename range_iterator<Col>::type iterator; 884 return auto_any_cast<iterator>(cur) == auto_any_cast<iterator>(end); 885 } 886 887 template<typename Col> 888 inline typename boost::enable_if< 889 boost::is_pointer<Col> 890 , bool 891 >::type 892 done(auto_any_t cur, auto_any_t, Col &) // null-terminated C-style strings 893 { 894 typedef typename range_iterator<Col>::type iterator; 895 return *auto_any_cast<iterator>(cur) == 0; 896 } 897 898 #else 735 899 template<typename T, typename C> 736 900 inline bool done(auto_any_t cur, auto_any_t end, type2type<T, C> *) 737 901 { … … 739 903 return auto_any_cast<iter_t, boost::mpl::false_>(cur) == auto_any_cast<iter_t, boost::mpl::false_>(end); 740 904 } 741 905 742 # ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING906 # ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING 743 907 template<typename T, typename C> 744 908 inline bool done(auto_any_t cur, auto_any_t, type2type<T *, C> *) // null-terminated C-style strings 745 909 { 746 910 return ! *auto_any_cast<T *, boost::mpl::false_>(cur); 747 911 } 912 # endif 748 913 #endif 749 914 750 915 /////////////////////////////////////////////////////////////////////////////// 751 916 // next 752 917 // 918 #if defined(BOOST_FOREACH_USE_CXX11) 919 template<typename Iterator, typename Col> 920 inline void next(Iterator &cur, Col &) 921 { 922 ++cur; 923 } 924 925 #elif defined(BOOST_FOREACH_USE_CXX11_GCC_WORKAROUND) 926 template<typename Col> 927 inline void next(auto_any_t cur, Col &) 928 { 929 typedef typename range_iterator<Col>::type iterator; 930 ++auto_any_cast<iterator>(cur); 931 } 932 933 #else 753 934 template<typename T, typename C> 754 935 inline void next(auto_any_t cur, type2type<T, C> *) 755 936 { 756 937 typedef BOOST_DEDUCED_TYPENAME foreach_iterator<T, C>::type iter_t; 757 938 ++auto_any_cast<iter_t, boost::mpl::false_>(cur); 758 939 } 940 #endif 759 941 760 942 /////////////////////////////////////////////////////////////////////////////// 761 943 // deref 762 944 // 945 #if defined(BOOST_FOREACH_USE_CXX11) 946 template<typename Iterator, typename Col> 947 inline typename range_reference<Col>::type 948 deref(Iterator const &cur, Col &) 949 { 950 return *cur; 951 } 952 953 #elif defined(BOOST_FOREACH_USE_CXX11_GCC_WORKAROUND) 954 template<typename Col> 955 inline typename range_reference<Col>::type 956 deref(auto_any_t cur, Col &) 957 { 958 typedef typename range_iterator<Col>::type iterator; 959 return *auto_any_cast<iterator>(cur); 960 } 961 962 #else 763 963 template<typename T, typename C> 764 964 inline BOOST_DEDUCED_TYPENAME foreach_reference<T, C>::type 765 965 deref(auto_any_t cur, type2type<T, C> *) … … 767 967 typedef BOOST_DEDUCED_TYPENAME foreach_iterator<T, C>::type iter_t; 768 968 return *auto_any_cast<iter_t, boost::mpl::false_>(cur); 769 969 } 970 #endif 770 971 771 972 ///////////////////////////////////////////////////////////////////////////// 772 973 // rbegin 773 974 // 975 #if defined(BOOST_FOREACH_USE_CXX11) || defined(BOOST_FOREACH_USE_CXX11_GCC_WORKAROUND) 976 template<typename T> 977 inline typename boost::disable_if< 978 boost::is_pointer<T> 979 , typename range_reverse_iterator<T>::type 980 >::type 981 rbegin(T &col) 982 { 983 return boost::rbegin(col); 984 } 985 986 template<typename T> 987 inline typename boost::enable_if< 988 boost::is_pointer<T> 989 , typename range_reverse_iterator<T>::type 990 >::type 991 rbegin(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 range_reverse_iterator<T>::type(p); 998 } 999 1000 #else 774 1001 template<typename T, typename C> 775 1002 inline auto_any<BOOST_DEDUCED_TYPENAME foreach_reverse_iterator<T, C>::type> 776 1003 rbegin(auto_any_t col, type2type<T, C> *, boost::mpl::true_ *) // rvalue … … 789 1016 iterator(boost::rbegin(derefof(auto_any_cast<type *, boost::mpl::false_>(col))))); 790 1017 } 791 1018 792 # ifdef BOOST_FOREACH_RUN_TIME_CONST_RVALUE_DETECTION1019 # ifdef BOOST_FOREACH_RUN_TIME_CONST_RVALUE_DETECTION 793 1020 template<typename T> 794 1021 inline auto_any<BOOST_DEDUCED_TYPENAME foreach_reverse_iterator<T, const_>::type> 795 1022 rbegin(auto_any_t col, type2type<T, const_> *, bool *) … … 797 1024 return auto_any<BOOST_DEDUCED_TYPENAME foreach_reverse_iterator<T, const_>::type>( 798 1025 boost::rbegin(*auto_any_cast<simple_variant<T>, boost::mpl::false_>(col).get())); 799 1026 } 800 # endif1027 # endif 801 1028 802 # ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING1029 # ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING 803 1030 template<typename T, typename C> 804 1031 inline auto_any<reverse_iterator<T *> > 805 1032 rbegin(auto_any_t col, type2type<T *, C> *, boost::mpl::true_ *) // null-terminated C-style strings … … 809 1036 ++p; 810 1037 return auto_any<reverse_iterator<T *> >(reverse_iterator<T *>(p)); 811 1038 } 1039 # endif 812 1040 #endif 813 1041 814 1042 /////////////////////////////////////////////////////////////////////////////// 815 1043 // rend 816 1044 // 1045 #if defined(BOOST_FOREACH_USE_CXX11) || defined(BOOST_FOREACH_USE_CXX11_GCC_WORKAROUND) 1046 template<typename T> 1047 inline typename boost::disable_if< 1048 boost::is_pointer<T> 1049 , typename range_reverse_iterator<T>::type 1050 >::type 1051 rend(T &col) 1052 { 1053 return boost::rend(col); 1054 } 1055 1056 template<typename T> 1057 inline typename boost::enable_if< 1058 boost::is_pointer<T> 1059 , typename range_reverse_iterator<T>::type 1060 >::type 1061 rend(T &col) // null-terminated C-style strings 1062 { 1063 return typename range_reverse_iterator<T>::type(col); 1064 } 1065 1066 #else 817 1067 template<typename T, typename C> 818 1068 inline auto_any<BOOST_DEDUCED_TYPENAME foreach_reverse_iterator<T, C>::type> 819 1069 rend(auto_any_t col, type2type<T, C> *, boost::mpl::true_ *) // rvalue … … 832 1082 iterator(boost::rend(derefof(auto_any_cast<type *, boost::mpl::false_>(col))))); 833 1083 } 834 1084 835 # ifdef BOOST_FOREACH_RUN_TIME_CONST_RVALUE_DETECTION1085 # ifdef BOOST_FOREACH_RUN_TIME_CONST_RVALUE_DETECTION 836 1086 template<typename T> 837 1087 inline auto_any<BOOST_DEDUCED_TYPENAME foreach_reverse_iterator<T, const_>::type> 838 1088 rend(auto_any_t col, type2type<T, const_> *, bool *) … … 840 1090 return auto_any<BOOST_DEDUCED_TYPENAME foreach_reverse_iterator<T, const_>::type>( 841 1091 boost::rend(*auto_any_cast<simple_variant<T>, boost::mpl::false_>(col).get())); 842 1092 } 843 # endif1093 # endif 844 1094 845 # ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING1095 # ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING 846 1096 template<typename T, typename C> 847 1097 inline auto_any<reverse_iterator<T *> > 848 1098 rend(auto_any_t col, type2type<T *, C> *, boost::mpl::true_ *) // null-terminated C-style strings … … 850 1100 return auto_any<reverse_iterator<T *> >( 851 1101 reverse_iterator<T *>(auto_any_cast<T *, boost::mpl::false_>(col))); 852 1102 } 1103 # endif 853 1104 #endif 854 1105 855 1106 /////////////////////////////////////////////////////////////////////////////// 856 1107 // rdone 857 1108 // 1109 #if defined(BOOST_FOREACH_USE_CXX11) 1110 template<typename Iterator, typename Col> 1111 inline 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) 1117 template<typename Col> 1118 inline bool rdone(auto_any_t cur, auto_any_t end, Col &) 1119 { 1120 typedef typename range_reverse_iterator<Col>::type iterator; 1121 return auto_any_cast<iterator>(cur) == auto_any_cast<iterator>(end); 1122 } 1123 1124 #else 858 1125 template<typename T, typename C> 859 1126 inline bool rdone(auto_any_t cur, auto_any_t end, type2type<T, C> *) 860 1127 { 861 1128 typedef BOOST_DEDUCED_TYPENAME foreach_reverse_iterator<T, C>::type iter_t; 862 1129 return auto_any_cast<iter_t, boost::mpl::false_>(cur) == auto_any_cast<iter_t, boost::mpl::false_>(end); 863 1130 } 1131 #endif 864 1132 865 1133 /////////////////////////////////////////////////////////////////////////////// 866 1134 // rnext 867 1135 // 1136 #if defined(BOOST_FOREACH_USE_CXX11) 1137 template<typename Iterator, typename Col> 1138 inline void rnext(Iterator &cur, Col &) 1139 { 1140 ++cur; 1141 } 1142 1143 #elif defined(BOOST_FOREACH_USE_CXX11_GCC_WORKAROUND) 1144 template<typename Col> 1145 inline void rnext(auto_any_t cur, Col &) 1146 { 1147 typedef typename range_reverse_iterator<Col>::type iterator; 1148 ++auto_any_cast<iterator>(cur); 1149 } 1150 1151 #else 868 1152 template<typename T, typename C> 869 1153 inline void rnext(auto_any_t cur, type2type<T, C> *) 870 1154 { 871 1155 typedef BOOST_DEDUCED_TYPENAME foreach_reverse_iterator<T, C>::type iter_t; 872 1156 ++auto_any_cast<iter_t, boost::mpl::false_>(cur); 873 1157 } 1158 #endif 874 1159 875 1160 /////////////////////////////////////////////////////////////////////////////// 876 1161 // rderef 877 1162 // 1163 #if defined(BOOST_FOREACH_USE_CXX11) 1164 template<typename Iterator, typename Col> 1165 inline typename range_reference<Col>::type 1166 rderef(Iterator const &cur, Col &) 1167 { 1168 return *cur; 1169 } 1170 1171 #elif defined(BOOST_FOREACH_USE_CXX11_GCC_WORKAROUND) 1172 template<typename Col> 1173 inline typename range_reference<Col>::type 1174 rderef(auto_any_t cur, Col &) 1175 { 1176 typedef typename range_reverse_iterator<Col>::type iterator; 1177 return *auto_any_cast<iterator>(cur); 1178 } 1179 1180 #else 878 1181 template<typename T, typename C> 879 1182 inline BOOST_DEDUCED_TYPENAME foreach_reference<T, C>::type 880 1183 rderef(auto_any_t cur, type2type<T, C> *) … … 882 1185 typedef BOOST_DEDUCED_TYPENAME foreach_reverse_iterator<T, C>::type iter_t; 883 1186 return *auto_any_cast<iter_t, boost::mpl::false_>(cur); 884 1187 } 1188 #endif 885 1189 886 1190 } // namespace foreach_detail_ 887 1191 } // namespace boost … … 904 1208 # define BOOST_FOREACH_ID(x) BOOST_PP_CAT(x, __LINE__) 905 1209 #endif 906 1210 1211 #if !defined(BOOST_FOREACH_USE_CXX11) && !defined(BOOST_FOREACH_USE_CXX11_GCC_WORKAROUND) 907 1212 // 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) \ 909 1214 (true ? 0 : boost::foreach_detail_::encode_type(COL, boost::foreach_detail_::is_const_(COL))) 910 1215 911 1216 // returns true_* if the type is noncopyable 912 # define BOOST_FOREACH_IS_NONCOPYABLE(COL)\1217 # define BOOST_FOREACH_IS_NONCOPYABLE(COL) \ 913 1218 boost_foreach_is_noncopyable( \ 914 1219 boost::foreach_detail_::to_ptr(COL) \ 915 1220 , boost_foreach_argument_dependent_lookup_hack_value) 916 1221 917 1222 // 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) \ 919 1224 boost::foreach_detail_::and_( \ 920 1225 boost::foreach_detail_::not_(BOOST_FOREACH_IS_NONCOPYABLE(COL)) \ 921 1226 , boost_foreach_is_lightweight_proxy( \ 922 1227 boost::foreach_detail_::to_ptr(COL) \ 923 1228 , boost_foreach_argument_dependent_lookup_hack_value)) 1229 #endif 924 1230 925 #if defined(BOOST_FOREACH_ COMPILE_TIME_CONST_RVALUE_DETECTION)1231 #if defined(BOOST_FOREACH_USE_CXX11) 926 1232 /////////////////////////////////////////////////////////////////////////////// 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 1240 namespace 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 1270 namespace 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 /////////////////////////////////////////////////////////////////////////////// 927 1298 // R-values and const R-values supported here with zero runtime overhead 928 1299 /////////////////////////////////////////////////////////////////////////////// 929 1300 … … 1005 1376 1006 1377 #endif 1007 1378 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) \ 1009 1483 boost::foreach_detail_::contain( \ 1010 1484 BOOST_FOREACH_EVALUATE(COL) \ 1011 1485 , BOOST_FOREACH_SHOULD_COPY(COL)) 1012 1486 1013 # define BOOST_FOREACH_BEGIN(COL)\1487 # define BOOST_FOREACH_BEGIN(COL) \ 1014 1488 boost::foreach_detail_::begin( \ 1015 1489 BOOST_FOREACH_ID(_foreach_col) \ 1016 1490 , BOOST_FOREACH_TYPEOF(COL) \ 1017 1491 , BOOST_FOREACH_SHOULD_COPY(COL)) 1018 1492 1019 # define BOOST_FOREACH_END(COL)\1493 # define BOOST_FOREACH_END(COL) \ 1020 1494 boost::foreach_detail_::end( \ 1021 1495 BOOST_FOREACH_ID(_foreach_col) \ 1022 1496 , BOOST_FOREACH_TYPEOF(COL) \ 1023 1497 , BOOST_FOREACH_SHOULD_COPY(COL)) 1024 1498 1025 # define BOOST_FOREACH_DONE(COL)\1499 # define BOOST_FOREACH_DONE(COL) \ 1026 1500 boost::foreach_detail_::done( \ 1027 1501 BOOST_FOREACH_ID(_foreach_cur) \ 1028 1502 , BOOST_FOREACH_ID(_foreach_end) \ 1029 1503 , BOOST_FOREACH_TYPEOF(COL)) 1030 1504 1031 # define BOOST_FOREACH_NEXT(COL)\1505 # define BOOST_FOREACH_NEXT(COL) \ 1032 1506 boost::foreach_detail_::next( \ 1033 1507 BOOST_FOREACH_ID(_foreach_cur) \ 1034 1508 , BOOST_FOREACH_TYPEOF(COL)) 1035 1509 1036 # define BOOST_FOREACH_DEREF(COL)\1510 # define BOOST_FOREACH_DEREF(COL) \ 1037 1511 boost::foreach_detail_::deref( \ 1038 1512 BOOST_FOREACH_ID(_foreach_cur) \ 1039 1513 , BOOST_FOREACH_TYPEOF(COL)) 1040 1514 1041 # define BOOST_FOREACH_RBEGIN(COL)\1515 # define BOOST_FOREACH_RBEGIN(COL) \ 1042 1516 boost::foreach_detail_::rbegin( \ 1043 1517 BOOST_FOREACH_ID(_foreach_col) \ 1044 1518 , BOOST_FOREACH_TYPEOF(COL) \ 1045 1519 , BOOST_FOREACH_SHOULD_COPY(COL)) 1046 1520 1047 # define BOOST_FOREACH_REND(COL)\1521 # define BOOST_FOREACH_REND(COL) \ 1048 1522 boost::foreach_detail_::rend( \ 1049 1523 BOOST_FOREACH_ID(_foreach_col) \ 1050 1524 , BOOST_FOREACH_TYPEOF(COL) \ 1051 1525 , BOOST_FOREACH_SHOULD_COPY(COL)) 1052 1526 1053 # define BOOST_FOREACH_RDONE(COL)\1527 # define BOOST_FOREACH_RDONE(COL) \ 1054 1528 boost::foreach_detail_::rdone( \ 1055 1529 BOOST_FOREACH_ID(_foreach_cur) \ 1056 1530 , BOOST_FOREACH_ID(_foreach_end) \ 1057 1531 , BOOST_FOREACH_TYPEOF(COL)) 1058 1532 1059 # define BOOST_FOREACH_RNEXT(COL)\1533 # define BOOST_FOREACH_RNEXT(COL) \ 1060 1534 boost::foreach_detail_::rnext( \ 1061 1535 BOOST_FOREACH_ID(_foreach_cur) \ 1062 1536 , BOOST_FOREACH_TYPEOF(COL)) 1063 1537 1064 # define BOOST_FOREACH_RDEREF(COL)\1538 # define BOOST_FOREACH_RDEREF(COL) \ 1065 1539 boost::foreach_detail_::rderef( \ 1066 1540 BOOST_FOREACH_ID(_foreach_cur) \ 1067 1541 , BOOST_FOREACH_TYPEOF(COL)) 1068 1542 1543 #endif 1544 1069 1545 /////////////////////////////////////////////////////////////////////////////// 1070 1546 // BOOST_FOREACH 1071 1547 // … … 1092 1568 // BOOST_FOREACH(i, int_list) 1093 1569 // { ... } 1094 1570 // 1095 #define BOOST_FOREACH(VAR, COL) \ 1571 #if defined(BOOST_FOREACH_USE_CXX11) 1572 # define BOOST_FOREACH(VAR, COL) \ 1096 1573 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() \ 1097 1606 if (boost::foreach_detail_::auto_any_t BOOST_FOREACH_ID(_foreach_col) = BOOST_FOREACH_CONTAIN(COL)) {} else \ 1098 1607 if (boost::foreach_detail_::auto_any_t BOOST_FOREACH_ID(_foreach_cur) = BOOST_FOREACH_BEGIN(COL)) {} else \ 1099 1608 if (boost::foreach_detail_::auto_any_t BOOST_FOREACH_ID(_foreach_end) = BOOST_FOREACH_END(COL)) {} else \ … … 1103 1612 if (boost::foreach_detail_::set_false(BOOST_FOREACH_ID(_foreach_continue))) {} else \ 1104 1613 for (VAR = BOOST_FOREACH_DEREF(COL); !BOOST_FOREACH_ID(_foreach_continue); BOOST_FOREACH_ID(_foreach_continue) = true) 1105 1614 1615 #endif 1616 1106 1617 /////////////////////////////////////////////////////////////////////////////// 1107 1618 // BOOST_REVERSE_FOREACH 1108 1619 // … … 1110 1621 // all other respects, BOOST_REVERSE_FOREACH is like 1111 1622 // BOOST_FOREACH. 1112 1623 // 1113 #define BOOST_REVERSE_FOREACH(VAR, COL) \ 1624 #if defined(BOOST_FOREACH_USE_CXX11) 1625 # define BOOST_REVERSE_FOREACH(VAR, COL) \ 1114 1626 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() \ 1115 1662 if (boost::foreach_detail_::auto_any_t BOOST_FOREACH_ID(_foreach_col) = BOOST_FOREACH_CONTAIN(COL)) {} else \ 1116 1663 if (boost::foreach_detail_::auto_any_t BOOST_FOREACH_ID(_foreach_cur) = BOOST_FOREACH_RBEGIN(COL)) {} else \ 1117 1664 if (boost::foreach_detail_::auto_any_t BOOST_FOREACH_ID(_foreach_end) = BOOST_FOREACH_REND(COL)) {} else \ … … 1122 1669 for (VAR = BOOST_FOREACH_RDEREF(COL); !BOOST_FOREACH_ID(_foreach_continue); BOOST_FOREACH_ID(_foreach_continue) = true) 1123 1670 1124 1671 #endif 1672 1673 #endif