annotate DEPENDENCIES/generic/include/boost/proto/repeat.hpp @ 125:34e428693f5d vext

Vext -> Repoint
author Chris Cannam
date Thu, 14 Jun 2018 11:15:39 +0100
parents 2665513ce2d3
children
rev   line source
Chris@16 1 ///////////////////////////////////////////////////////////////////////////////
Chris@16 2 /// \file repeat.hpp
Chris@16 3 /// Contains macros to ease the generation of repetitious code constructs
Chris@16 4 //
Chris@16 5 // Copyright 2008 Eric Niebler. Distributed under the Boost
Chris@16 6 // Software License, Version 1.0. (See accompanying file
Chris@16 7 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
Chris@16 8
Chris@16 9 #ifndef BOOST_PROTO_REPEAT_HPP_EAN_11_24_2008
Chris@16 10 #define BOOST_PROTO_REPEAT_HPP_EAN_11_24_2008
Chris@16 11
Chris@16 12 #include <boost/preprocessor/cat.hpp>
Chris@16 13 #include <boost/preprocessor/facilities/intercept.hpp>
Chris@16 14 #include <boost/preprocessor/repetition/enum.hpp>
Chris@16 15 #include <boost/preprocessor/repetition/enum_params.hpp>
Chris@16 16 #include <boost/preprocessor/repetition/enum_binary_params.hpp>
Chris@16 17 #include <boost/preprocessor/iteration/local.hpp>
Chris@16 18 #include <boost/preprocessor/tuple/elem.hpp>
Chris@16 19 #include <boost/proto/proto_fwd.hpp> // for BOOST_PROTO_MAX_ARITY
Chris@16 20
Chris@16 21 ////////////////////////////////////////////
Chris@16 22 /// INTERNAL ONLY
Chris@16 23 #define BOOST_PROTO_ref_a_aux(Z, N, DATA)\
Chris@16 24 boost::ref(BOOST_PP_CAT(proto_a, N))
Chris@16 25
Chris@16 26 /// \brief Generates a sequence like <tt>typename A0, typename A1, ...</tt>
Chris@16 27 ///
Chris@16 28 #define BOOST_PROTO_typename_A(N)\
Chris@16 29 BOOST_PP_ENUM_PARAMS(N, typename proto_A)
Chris@16 30
Chris@16 31 /// \brief Generates a sequence like <tt>A0 const &, A1 const &, ...</tt>
Chris@16 32 ///
Chris@16 33 #define BOOST_PROTO_A_const_ref(N)\
Chris@16 34 BOOST_PP_ENUM_BINARY_PARAMS(N, proto_A, const & BOOST_PP_INTERCEPT)
Chris@16 35
Chris@16 36 /// \brief Generates a sequence like <tt>A0 &, A1 &, ...</tt>
Chris@16 37 ///
Chris@16 38 #define BOOST_PROTO_A_ref(N)\
Chris@16 39 BOOST_PP_ENUM_BINARY_PARAMS(N, proto_A, & BOOST_PP_INTERCEPT)
Chris@16 40
Chris@16 41 /// \brief Generates a sequence like <tt>A0, A1, ...</tt>
Chris@16 42 ///
Chris@16 43 #define BOOST_PROTO_A(N)\
Chris@16 44 BOOST_PP_ENUM_PARAMS(N, proto_A)
Chris@16 45
Chris@16 46 /// \brief Generates a sequence like <tt>A0 const, A1 const, ...</tt>
Chris@16 47 ///
Chris@16 48 #define BOOST_PROTO_A_const(N)\
Chris@16 49 BOOST_PP_ENUM_PARAMS(N, const proto_A)
Chris@16 50
Chris@16 51 /// \brief Generates a sequence like <tt>A0 const &a0, A1 const &a0, ...</tt>
Chris@16 52 ///
Chris@16 53 #define BOOST_PROTO_A_const_ref_a(N)\
Chris@16 54 BOOST_PP_ENUM_BINARY_PARAMS(N, proto_A, const &proto_a)
Chris@16 55
Chris@16 56 /// \brief Generates a sequence like <tt>A0 &a0, A1 &a0, ...</tt>
Chris@16 57 ///
Chris@16 58 #define BOOST_PROTO_A_ref_a(N)\
Chris@16 59 BOOST_PP_ENUM_BINARY_PARAMS(N, proto_A, &proto_a)
Chris@16 60
Chris@16 61 /// \brief Generates a sequence like <tt>boost::ref(a0), boost::ref(a1), ...</tt>
Chris@16 62 ///
Chris@16 63 #define BOOST_PROTO_ref_a(N)\
Chris@16 64 BOOST_PP_ENUM(N, BOOST_PROTO_ref_a_aux, ~)
Chris@16 65
Chris@16 66 /// \brief Generates a sequence like <tt>a0, a1, ...</tt>
Chris@16 67 ///
Chris@16 68 #define BOOST_PROTO_a(N)\
Chris@16 69 BOOST_PP_ENUM_PARAMS(N, proto_a)
Chris@16 70
Chris@16 71 ////////////////////////////////////////////
Chris@16 72 /// INTERNAL ONLY
Chris@16 73 #define BOOST_PROTO_invoke(Z, N, DATA)\
Chris@16 74 BOOST_PP_TUPLE_ELEM(5,0,DATA)(N, BOOST_PP_TUPLE_ELEM(5,1,DATA), BOOST_PP_TUPLE_ELEM(5,2,DATA), BOOST_PP_TUPLE_ELEM(5,3,DATA), BOOST_PP_TUPLE_ELEM(5,4,DATA))
Chris@16 75
Chris@16 76 /// \brief Repeatedly invoke the specified macro.
Chris@16 77 ///
Chris@16 78 /// BOOST_PROTO_REPEAT_FROM_TO_EX() is used generate the kind of repetitive code that is typical
Chris@16 79 /// of EDSLs built with Proto. BOOST_PROTO_REPEAT_FROM_TO_EX(FROM, TO, MACRO, typename_A, A, A_a, a) is equivalent to:
Chris@16 80 ///
Chris@16 81 /// \code
Chris@16 82 /// MACRO(FROM, typename_A, A, A_a, a)
Chris@16 83 /// MACRO(FROM+1, typename_A, A, A_a, a)
Chris@16 84 /// ...
Chris@16 85 /// MACRO(TO-1, typename_A, A, A_a, a)
Chris@16 86 /// \endcode
Chris@16 87 #define BOOST_PROTO_REPEAT_FROM_TO_EX(FROM, TO, MACRO, typename_A, A, A_a, a)\
Chris@16 88 BOOST_PP_REPEAT_FROM_TO(FROM, TO, BOOST_PROTO_invoke, (MACRO, typename_A, A, A_a, a))
Chris@16 89
Chris@16 90 /// \brief Repeatedly invoke the specified macro.
Chris@16 91 ///
Chris@16 92 /// BOOST_PROTO_REPEAT_FROM_TO() is used generate the kind of repetitive code that is typical
Chris@16 93 /// of EDSLs built with Proto. BOOST_PROTO_REPEAT_FROM_TO(FROM, TO, MACRO) is equivalent to:
Chris@16 94 ///
Chris@16 95 /// \code
Chris@16 96 /// MACRO(FROM, BOOST_PROTO_typename_A, BOOST_PROTO_A_const_ref, BOOST_PROTO_A_const_ref_a, BOOST_PROTO_ref_a)
Chris@16 97 /// MACRO(FROM+1, BOOST_PROTO_typename_A, BOOST_PROTO_A_const_ref, BOOST_PROTO_A_const_ref_a, BOOST_PROTO_ref_a)
Chris@16 98 /// ...
Chris@16 99 /// MACRO(TO-1, BOOST_PROTO_typename_A, BOOST_PROTO_A_const_ref, BOOST_PROTO_A_const_ref_a, BOOST_PROTO_ref_a)
Chris@16 100 /// \endcode
Chris@16 101 ///
Chris@16 102 /// Example:
Chris@16 103 ///
Chris@16 104 /** \code
Chris@16 105
Chris@16 106 // Generate BOOST_PROTO_MAX_ARITY-1 overloads of the
Chris@16 107 // following construct() function template.
Chris@16 108 #define M0(N, typename_A, A_const_ref, A_const_ref_a, ref_a) \
Chris@16 109 template<typename T, typename_A(N)> \
Chris@16 110 typename proto::result_of::make_expr< \
Chris@16 111 proto::tag::function \
Chris@16 112 , construct_helper<T> \
Chris@16 113 , A_const_ref(N) \
Chris@16 114 >::type const \
Chris@16 115 construct(A_const_ref_a(N)) \
Chris@16 116 { \
Chris@16 117 return proto::make_expr< \
Chris@16 118 proto::tag::function \
Chris@16 119 >( \
Chris@16 120 construct_helper<T>() \
Chris@16 121 , ref_a(N) \
Chris@16 122 ); \
Chris@16 123 }
Chris@16 124 BOOST_PROTO_REPEAT_FROM_TO(1, BOOST_PROTO_MAX_ARITY, M0)
Chris@16 125 #undef M0
Chris@16 126
Chris@16 127 \endcode
Chris@16 128 **/
Chris@16 129 /// The above invocation of BOOST_PROTO_REPEAT_FROM_TO() will generate
Chris@16 130 /// the following code:
Chris@16 131 ///
Chris@16 132 /// \code
Chris@16 133 /// template<typename T, typename A0>
Chris@16 134 /// typename proto::result_of::make_expr<
Chris@16 135 /// proto::tag::function
Chris@16 136 /// , construct_helper<T>
Chris@16 137 /// , A0 const &
Chris@16 138 /// >::type const
Chris@16 139 /// construct(A0 const & a0)
Chris@16 140 /// {
Chris@16 141 /// return proto::make_expr<
Chris@16 142 /// proto::tag::function
Chris@16 143 /// >(
Chris@16 144 /// construct_helper<T>()
Chris@16 145 /// , boost::ref(a0)
Chris@16 146 /// );
Chris@16 147 /// }
Chris@16 148 ///
Chris@16 149 /// template<typename T, typename A0, typename A1>
Chris@16 150 /// typename proto::result_of::make_expr<
Chris@16 151 /// proto::tag::function
Chris@16 152 /// , construct_helper<T>
Chris@16 153 /// , A0 const &
Chris@16 154 /// , A1 const &
Chris@16 155 /// >::type const
Chris@16 156 /// construct(A0 const & a0, A1 const & a1)
Chris@16 157 /// {
Chris@16 158 /// return proto::make_expr<
Chris@16 159 /// proto::tag::function
Chris@16 160 /// >(
Chris@16 161 /// construct_helper<T>()
Chris@16 162 /// , boost::ref(a0)
Chris@16 163 /// , boost::ref(a1)
Chris@16 164 /// );
Chris@16 165 /// }
Chris@16 166 ///
Chris@16 167 /// // ... and so on, up to BOOST_PROTO_MAX_ARITY-1 arguments ...
Chris@16 168 /// \endcode
Chris@16 169 #define BOOST_PROTO_REPEAT_FROM_TO(FROM, TO, MACRO)\
Chris@16 170 BOOST_PROTO_REPEAT_FROM_TO_EX(FROM, TO, MACRO, BOOST_PROTO_typename_A, BOOST_PROTO_A_const_ref, BOOST_PROTO_A_const_ref_a, BOOST_PROTO_ref_a)
Chris@16 171
Chris@16 172 /// \brief Repeatedly invoke the specified macro.
Chris@16 173 ///
Chris@16 174 /// BOOST_PROTO_REPEAT_EX() is used generate the kind of repetitive code that is typical
Chris@16 175 /// of EDSLs built with Proto. BOOST_PROTO_REPEAT_EX(MACRO, typename_A, A, A_a, a) is equivalent to:
Chris@16 176 ///
Chris@16 177 /// \code
Chris@16 178 /// MACRO(1, typename_A, A, A_a, a)
Chris@16 179 /// MACRO(2, typename_A, A, A_a, a)
Chris@16 180 /// ...
Chris@16 181 /// MACRO(BOOST_PROTO_MAX_ARITY, typename_A, A, A_a, a)
Chris@16 182 /// \endcode
Chris@16 183 #define BOOST_PROTO_REPEAT_EX(MACRO, typename_A, A, A_a, a)\
Chris@16 184 BOOST_PROTO_REPEAT_FROM_TO_EX(1, BOOST_PP_INC(BOOST_PROTO_MAX_ARITY), MACRO, BOOST_PROTO_typename_A, BOOST_PROTO_A_const_ref, BOOST_PROTO_A_const_ref_a, BOOST_PROTO_ref_a)
Chris@16 185
Chris@16 186 /// \brief Repeatedly invoke the specified macro.
Chris@16 187 ///
Chris@16 188 /// BOOST_PROTO_REPEAT() is used generate the kind of repetitive code that is typical
Chris@16 189 /// of EDSLs built with Proto. BOOST_PROTO_REPEAT(MACRO) is equivalent to:
Chris@16 190 ///
Chris@16 191 /// \code
Chris@16 192 /// MACRO(1, BOOST_PROTO_typename_A, BOOST_PROTO_A_const_ref, BOOST_PROTO_A_const_ref_a, BOOST_PROTO_ref_a)
Chris@16 193 /// MACRO(2, BOOST_PROTO_typename_A, BOOST_PROTO_A_const_ref, BOOST_PROTO_A_const_ref_a, BOOST_PROTO_ref_a)
Chris@16 194 /// ...
Chris@16 195 /// MACRO(BOOST_PROTO_MAX_ARITY, BOOST_PROTO_typename_A, BOOST_PROTO_A_const_ref, BOOST_PROTO_A_const_ref_a, BOOST_PROTO_ref_a)
Chris@16 196 /// \endcode
Chris@16 197 #define BOOST_PROTO_REPEAT(MACRO)\
Chris@16 198 BOOST_PROTO_REPEAT_FROM_TO(1, BOOST_PP_INC(BOOST_PROTO_MAX_ARITY), MACRO)
Chris@16 199
Chris@16 200 /// \brief Repeatedly invoke the specified macro.
Chris@16 201 ///
Chris@16 202 /// BOOST_PROTO_LOCAL_ITERATE() is used generate the kind of repetitive code that is typical
Chris@16 203 /// of EDSLs built with Proto. This macro causes the user-defined macro BOOST_PROTO_LOCAL_MACRO to
Chris@16 204 /// be expanded with values in the range specified by BOOST_PROTO_LOCAL_LIMITS.
Chris@16 205 ///
Chris@16 206 /// Usage:
Chris@16 207 ///
Chris@16 208 /// \code
Chris@16 209 /// #include BOOST_PROTO_LOCAL_ITERATE()
Chris@16 210 /// \endcode
Chris@16 211 ///
Chris@16 212 /// Example:
Chris@16 213 ///
Chris@16 214 /** \code
Chris@16 215
Chris@16 216 // Generate BOOST_PROTO_MAX_ARITY-1 overloads of the
Chris@16 217 // following construct() function template.
Chris@16 218 #define BOOST_PROTO_LOCAL_MACRO(N, typename_A, A_const_ref, \
Chris@16 219 A_const_ref_a, ref_a) \
Chris@16 220 template<typename T, typename_A(N)> \
Chris@16 221 typename proto::result_of::make_expr< \
Chris@16 222 proto::tag::function \
Chris@16 223 , construct_helper<T> \
Chris@16 224 , A_const_ref(N) \
Chris@16 225 >::type const \
Chris@16 226 construct(A_const_ref_a(N)) \
Chris@16 227 { \
Chris@16 228 return proto::make_expr< \
Chris@16 229 proto::tag::function \
Chris@16 230 >( \
Chris@16 231 construct_helper<T>() \
Chris@16 232 , ref_a(N) \
Chris@16 233 ); \
Chris@16 234 }
Chris@16 235 #define BOOST_PROTO_LOCAL_LIMITS (1, BOOST_PP_DEC(BOOST_PROTO_MAX_ARITY))
Chris@16 236 #include BOOST_PROTO_LOCAL_ITERATE()
Chris@16 237
Chris@16 238 \endcode
Chris@16 239 **/
Chris@16 240 /// The above inclusion of BOOST_PROTO_LOCAL_ITERATE() will generate
Chris@16 241 /// the following code:
Chris@16 242 ///
Chris@16 243 /// \code
Chris@16 244 /// template<typename T, typename A0>
Chris@16 245 /// typename proto::result_of::make_expr<
Chris@16 246 /// proto::tag::function
Chris@16 247 /// , construct_helper<T>
Chris@16 248 /// , A0 const &
Chris@16 249 /// >::type const
Chris@16 250 /// construct(A0 const & a0)
Chris@16 251 /// {
Chris@16 252 /// return proto::make_expr<
Chris@16 253 /// proto::tag::function
Chris@16 254 /// >(
Chris@16 255 /// construct_helper<T>()
Chris@16 256 /// , boost::ref(a0)
Chris@16 257 /// );
Chris@16 258 /// }
Chris@16 259 ///
Chris@16 260 /// template<typename T, typename A0, typename A1>
Chris@16 261 /// typename proto::result_of::make_expr<
Chris@16 262 /// proto::tag::function
Chris@16 263 /// , construct_helper<T>
Chris@16 264 /// , A0 const &
Chris@16 265 /// , A1 const &
Chris@16 266 /// >::type const
Chris@16 267 /// construct(A0 const & a0, A1 const & a1)
Chris@16 268 /// {
Chris@16 269 /// return proto::make_expr<
Chris@16 270 /// proto::tag::function
Chris@16 271 /// >(
Chris@16 272 /// construct_helper<T>()
Chris@16 273 /// , boost::ref(a0)
Chris@16 274 /// , boost::ref(a1)
Chris@16 275 /// );
Chris@16 276 /// }
Chris@16 277 ///
Chris@16 278 /// // ... and so on, up to BOOST_PROTO_MAX_ARITY-1 arguments ...
Chris@16 279 /// \endcode
Chris@16 280 ///
Chris@16 281 /// If BOOST_PROTO_LOCAL_LIMITS is not defined by the user, it defaults
Chris@16 282 /// to (1, BOOST_PROTO_MAX_ARITY)
Chris@16 283 ///
Chris@16 284 /// At each iteration, BOOST_PROTO_LOCAL_MACRO is invoked with the current
Chris@16 285 /// iteration number and the following 4 macro parameters:
Chris@16 286 ///
Chris@16 287 /// \li BOOST_PROTO_LOCAL_typename_A
Chris@16 288 /// \li BOOST_PROTO_LOCAL_A
Chris@16 289 /// \li BOOST_PROTO_LOCAL_A_a
Chris@16 290 /// \li BOOST_PROTO_LOCAL_a
Chris@16 291 ///
Chris@16 292 /// If these macros are not defined by the user, they default respectively to:
Chris@16 293 ///
Chris@16 294 /// \li BOOST_PROTO_typename_A
Chris@16 295 /// \li BOOST_PROTO_A_const_ref
Chris@16 296 /// \li BOOST_PROTO_A_const_ref_a
Chris@16 297 /// \li BOOST_PROTO_ref_a
Chris@16 298 ///
Chris@16 299 /// After including BOOST_PROTO_LOCAL_ITERATE(), the following macros are
Chris@16 300 /// automatically undefined:
Chris@16 301 ///
Chris@16 302 /// \li BOOST_PROTO_LOCAL_MACRO
Chris@16 303 /// \li BOOST_PROTO_LOCAL_LIMITS
Chris@16 304 /// \li BOOST_PROTO_LOCAL_typename_A
Chris@16 305 /// \li BOOST_PROTO_LOCAL_A
Chris@16 306 /// \li BOOST_PROTO_LOCAL_A_a
Chris@16 307 /// \li BOOST_PROTO_LOCAL_a
Chris@16 308 #define BOOST_PROTO_LOCAL_ITERATE() <boost/proto/detail/local.hpp>
Chris@16 309
Chris@16 310 #endif