Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/range/v3/range_for.hpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 /// \file
0002 // Range v3 library
0003 //
0004 //  Copyright Eric Niebler 2014-present
0005 //
0006 //  Use, modification and distribution is subject to the
0007 //  Boost Software License, Version 1.0. (See accompanying
0008 //  file LICENSE_1_0.txt or copy at
0009 //  http://www.boost.org/LICENSE_1_0.txt)
0010 //
0011 // Project home: https://github.com/ericniebler/range-v3
0012 //
0013 
0014 #ifndef RANGES_V3_RANGE_FOR_HPP
0015 #define RANGES_V3_RANGE_FOR_HPP
0016 
0017 #include <range/v3/range_fwd.hpp>
0018 
0019 #include <range/v3/range/access.hpp>
0020 
0021 #if RANGES_CXX_RANGE_BASED_FOR < RANGES_CXX_RANGE_BASED_FOR_17
0022 /// A range-based for macro, basically a hack until the built-in range-for can handle
0023 /// Ranges that have a different type for begin and end. \ingroup range-core
0024 #define RANGES_FOR(VAR_DECL, ...)                                              \
0025     if(bool CPP_PP_CAT(_range_v3_done, __LINE__) = false) {}                   \
0026     else                                                                       \
0027         for(auto && CPP_PP_CAT(_range_v3_rng, __LINE__) = (__VA_ARGS__);       \
0028             !CPP_PP_CAT(_range_v3_done, __LINE__);)                            \
0029             for(auto CPP_PP_CAT(_range_v3_begin, __LINE__) =                   \
0030                     ranges::begin(CPP_PP_CAT(_range_v3_rng, __LINE__));        \
0031                 !CPP_PP_CAT(_range_v3_done, __LINE__);                         \
0032                 CPP_PP_CAT(_range_v3_done, __LINE__) = true)                   \
0033                 for(auto CPP_PP_CAT(_range_v3_end, __LINE__) =                 \
0034                         ranges::end(CPP_PP_CAT(_range_v3_rng, __LINE__));      \
0035                     !CPP_PP_CAT(_range_v3_done, __LINE__) &&                   \
0036                     CPP_PP_CAT(_range_v3_begin, __LINE__) !=                   \
0037                         CPP_PP_CAT(_range_v3_end, __LINE__);                   \
0038                     ++CPP_PP_CAT(_range_v3_begin, __LINE__))                   \
0039                     if(!(CPP_PP_CAT(_range_v3_done, __LINE__) = true)) {}      \
0040                     else                                                       \
0041                         for(VAR_DECL = *CPP_PP_CAT(_range_v3_begin, __LINE__); \
0042                             CPP_PP_CAT(_range_v3_done, __LINE__);              \
0043                             CPP_PP_CAT(_range_v3_done, __LINE__) = false)      \
0044     /**/
0045 
0046 #else
0047 #define RANGES_FOR(VAR_DECL, ...) for(VAR_DECL : (__VA_ARGS__))
0048 #endif
0049 
0050 #endif