Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 1 | |
| 2 | // NO INCLUDE GUARDS, THE HEADER IS INTENDED FOR MULTIPLE INCLUSION |
| 3 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 4 | #if !defined(NDNBOOST_PP_IS_ITERATING) |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 5 | |
| 6 | ///// header body |
| 7 | |
| 8 | // Copyright Aleksey Gurtovoy 2000-2008 |
| 9 | // |
| 10 | // Distributed under the Boost Software License, Version 1.0. |
| 11 | // (See accompanying file LICENSE_1_0.txt or copy at |
| 12 | // http://www.boost.org/LICENSE_1_0.txt) |
| 13 | // |
| 14 | // See http://www.boost.org/libs/mpl for documentation. |
| 15 | |
| 16 | // $Id: sequence_wrapper.hpp 49271 2008-10-11 06:46:00Z agurtovoy $ |
| 17 | // $Date: 2008-10-10 23:46:00 -0700 (Fri, 10 Oct 2008) $ |
| 18 | // $Revision: 49271 $ |
| 19 | |
| 20 | # include <ndnboost/mpl/aux_/config/ctps.hpp> |
| 21 | # include <ndnboost/mpl/aux_/config/static_constant.hpp> |
| 22 | # include <ndnboost/mpl/aux_/nttp_decl.hpp> |
| 23 | |
| 24 | # include <ndnboost/preprocessor/arithmetic/sub.hpp> |
| 25 | # include <ndnboost/preprocessor/tuple/elem.hpp> |
| 26 | # include <ndnboost/preprocessor/enum_params_with_a_default.hpp> |
| 27 | # include <ndnboost/preprocessor/enum_params.hpp> |
| 28 | # include <ndnboost/preprocessor/enum.hpp> |
| 29 | # include <ndnboost/preprocessor/repeat.hpp> |
| 30 | # include <ndnboost/preprocessor/comma_if.hpp> |
| 31 | # include <ndnboost/preprocessor/iterate.hpp> |
| 32 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 33 | #if defined(NDNBOOST_MPL_PREPROCESSING_MODE) |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 34 | # undef LONG_MAX |
| 35 | #endif |
| 36 | |
| 37 | namespace ndnboost { namespace mpl { |
| 38 | |
| 39 | #if !defined(AUX778076_SEQUENCE_BASE_NAME) |
| 40 | # define AUX778076_SEQUENCE_BASE_NAME AUX778076_SEQUENCE_NAME |
| 41 | #endif |
| 42 | |
| 43 | #if !defined(AUX778076_SEQUENCE_INTEGRAL_WRAPPER) |
| 44 | |
| 45 | # define AUX778076_SEQUENCE_PARAM_NAME T |
| 46 | # define AUX778076_SEQUENCE_TEMPLATE_PARAM typename T |
| 47 | # define AUX778076_SEQUENCE_DEFAULT na |
| 48 | |
| 49 | # define AUX778076_SEQUENCE_NAME_N(n) \ |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 50 | NDNBOOST_PP_CAT(AUX778076_SEQUENCE_BASE_NAME,n) \ |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 51 | /**/ |
| 52 | |
| 53 | # define AUX778076_SEQUENCE_PARAMS() \ |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 54 | NDNBOOST_PP_ENUM_PARAMS( \ |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 55 | AUX778076_SEQUENCE_LIMIT \ |
| 56 | , AUX778076_SEQUENCE_TEMPLATE_PARAM \ |
| 57 | ) \ |
| 58 | /**/ |
| 59 | |
| 60 | # define AUX778076_SEQUENCE_ARGS() \ |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 61 | NDNBOOST_PP_ENUM_PARAMS( \ |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 62 | AUX778076_SEQUENCE_LIMIT \ |
| 63 | , T \ |
| 64 | ) \ |
| 65 | /**/ |
| 66 | |
| 67 | # define AUX778076_SEQUENCE_DEFAULT_PARAMS() \ |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 68 | NDNBOOST_PP_ENUM_PARAMS_WITH_A_DEFAULT( \ |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 69 | AUX778076_SEQUENCE_LIMIT \ |
| 70 | , AUX778076_SEQUENCE_TEMPLATE_PARAM \ |
| 71 | , AUX778076_SEQUENCE_DEFAULT \ |
| 72 | ) \ |
| 73 | /**/ |
| 74 | |
| 75 | # define AUX778076_SEQUENCE_N_PARAMS(n) \ |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 76 | NDNBOOST_PP_ENUM_PARAMS(n, AUX778076_SEQUENCE_TEMPLATE_PARAM) \ |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 77 | /**/ |
| 78 | |
| 79 | # define AUX778076_SEQUENCE_N_ARGS(n) \ |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 80 | NDNBOOST_PP_ENUM_PARAMS(n, T) \ |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 81 | /**/ |
| 82 | |
| 83 | # define AUX778076_SEQUENCE_N_PARTIAL_SPEC_ARGS(n) \ |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 84 | NDNBOOST_PP_ENUM_PARAMS(n, T) \ |
| 85 | NDNBOOST_PP_COMMA_IF(n) \ |
| 86 | NDNBOOST_PP_ENUM( \ |
| 87 | NDNBOOST_PP_SUB_D(1,AUX778076_SEQUENCE_LIMIT,n) \ |
| 88 | , NDNBOOST_PP_TUPLE_ELEM_3_2 \ |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 89 | , AUX778076_SEQUENCE_DEFAULT \ |
| 90 | ) \ |
| 91 | /**/ |
| 92 | |
| 93 | #else // AUX778076_SEQUENCE_INTEGRAL_WRAPPER |
| 94 | |
| 95 | # define AUX778076_SEQUENCE_PARAM_NAME C |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 96 | # define AUX778076_SEQUENCE_TEMPLATE_PARAM NDNBOOST_MPL_AUX_NTTP_DECL(long, C) |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 97 | # define AUX778076_SEQUENCE_DEFAULT LONG_MAX |
| 98 | |
| 99 | # define AUX778076_SEQUENCE_PARAMS() \ |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 100 | typename T, NDNBOOST_PP_ENUM_PARAMS( \ |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 101 | AUX778076_SEQUENCE_LIMIT \ |
| 102 | , AUX778076_SEQUENCE_TEMPLATE_PARAM \ |
| 103 | ) \ |
| 104 | /**/ |
| 105 | |
| 106 | # define AUX778076_SEQUENCE_ARGS() \ |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 107 | T, NDNBOOST_PP_ENUM_PARAMS( \ |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 108 | AUX778076_SEQUENCE_LIMIT \ |
| 109 | , C \ |
| 110 | ) \ |
| 111 | /**/ |
| 112 | |
| 113 | # define AUX778076_SEQUENCE_DEFAULT_PARAMS() \ |
| 114 | typename T, \ |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 115 | NDNBOOST_PP_ENUM_PARAMS_WITH_A_DEFAULT( \ |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 116 | AUX778076_SEQUENCE_LIMIT \ |
| 117 | , AUX778076_SEQUENCE_TEMPLATE_PARAM \ |
| 118 | , AUX778076_SEQUENCE_DEFAULT \ |
| 119 | ) \ |
| 120 | /**/ |
| 121 | |
| 122 | # define AUX778076_SEQUENCE_N_PARAMS(n) \ |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 123 | typename T NDNBOOST_PP_COMMA_IF(n) \ |
| 124 | NDNBOOST_PP_ENUM_PARAMS(n, AUX778076_SEQUENCE_TEMPLATE_PARAM) \ |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 125 | /**/ |
| 126 | |
| 127 | # if !defined(AUX778076_SEQUENCE_CONVERT_CN_TO) |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 128 | # define AUX778076_SEQUENCE_CONVERT_CN_TO(z,n,TARGET) NDNBOOST_PP_CAT(C,n) |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 129 | # endif |
| 130 | |
| 131 | # define AUX778076_SEQUENCE_N_ARGS(n) \ |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 132 | T NDNBOOST_PP_COMMA_IF(n) \ |
| 133 | NDNBOOST_PP_ENUM(n,AUX778076_SEQUENCE_CONVERT_CN_TO,T) \ |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 134 | /**/ |
| 135 | |
| 136 | # define AUX778076_SEQUENCE_N_PARTIAL_SPEC_ARGS(n) \ |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 137 | T, NDNBOOST_PP_ENUM_PARAMS(n, C) \ |
| 138 | NDNBOOST_PP_COMMA_IF(n) \ |
| 139 | NDNBOOST_PP_ENUM( \ |
| 140 | NDNBOOST_PP_SUB_D(1,AUX778076_SEQUENCE_LIMIT,n) \ |
| 141 | , NDNBOOST_PP_TUPLE_ELEM_3_2 \ |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 142 | , AUX778076_SEQUENCE_DEFAULT \ |
| 143 | ) \ |
| 144 | /**/ |
| 145 | |
| 146 | #endif // AUX778076_SEQUENCE_INTEGRAL_WRAPPER |
| 147 | |
| 148 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 149 | #if !defined(NDNBOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 150 | // forward declaration |
| 151 | template< |
| 152 | AUX778076_SEQUENCE_DEFAULT_PARAMS() |
| 153 | > |
| 154 | struct AUX778076_SEQUENCE_NAME; |
| 155 | #else |
| 156 | namespace aux { |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 157 | template< NDNBOOST_MPL_AUX_NTTP_DECL(int, N) > |
| 158 | struct NDNBOOST_PP_CAT(AUX778076_SEQUENCE_NAME,_chooser); |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 159 | } |
| 160 | #endif |
| 161 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 162 | #define NDNBOOST_PP_ITERATION_PARAMS_1 \ |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 163 | (3,(0, AUX778076_SEQUENCE_LIMIT, <ndnboost/mpl/aux_/sequence_wrapper.hpp>)) |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 164 | #include NDNBOOST_PP_ITERATE() |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 165 | |
| 166 | // real C++ version is already taken care of |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 167 | #if defined(NDNBOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 168 | |
| 169 | namespace aux { |
| 170 | // ???_count_args |
| 171 | #define AUX778076_COUNT_ARGS_PREFIX AUX778076_SEQUENCE_NAME |
| 172 | #define AUX778076_COUNT_ARGS_DEFAULT AUX778076_SEQUENCE_DEFAULT |
| 173 | #define AUX778076_COUNT_ARGS_PARAM_NAME AUX778076_SEQUENCE_PARAM_NAME |
| 174 | #define AUX778076_COUNT_ARGS_TEMPLATE_PARAM AUX778076_SEQUENCE_TEMPLATE_PARAM |
| 175 | #define AUX778076_COUNT_ARGS_ARITY AUX778076_SEQUENCE_LIMIT |
| 176 | #define AUX778076_COUNT_ARGS_USE_STANDARD_PP_PRIMITIVES |
| 177 | #include <ndnboost/mpl/aux_/count_args.hpp> |
| 178 | |
| 179 | template< |
| 180 | AUX778076_SEQUENCE_PARAMS() |
| 181 | > |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 182 | struct NDNBOOST_PP_CAT(AUX778076_SEQUENCE_NAME,_impl) |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 183 | { |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 184 | typedef aux::NDNBOOST_PP_CAT(AUX778076_SEQUENCE_NAME,_count_args)< |
| 185 | NDNBOOST_PP_ENUM_PARAMS(AUX778076_SEQUENCE_LIMIT, AUX778076_SEQUENCE_PARAM_NAME) |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 186 | > arg_num_; |
| 187 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 188 | typedef typename aux::NDNBOOST_PP_CAT(AUX778076_SEQUENCE_NAME,_chooser)< arg_num_::value > |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 189 | ::template result_< AUX778076_SEQUENCE_ARGS() >::type type; |
| 190 | }; |
| 191 | |
| 192 | } // namespace aux |
| 193 | |
| 194 | template< |
| 195 | AUX778076_SEQUENCE_DEFAULT_PARAMS() |
| 196 | > |
| 197 | struct AUX778076_SEQUENCE_NAME |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 198 | : aux::NDNBOOST_PP_CAT(AUX778076_SEQUENCE_NAME,_impl)< |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 199 | AUX778076_SEQUENCE_ARGS() |
| 200 | >::type |
| 201 | { |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 202 | typedef typename aux::NDNBOOST_PP_CAT(AUX778076_SEQUENCE_NAME,_impl)< |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 203 | AUX778076_SEQUENCE_ARGS() |
| 204 | >::type type; |
| 205 | }; |
| 206 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 207 | #endif // NDNBOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 208 | |
| 209 | # undef AUX778076_SEQUENCE_N_PARTIAL_SPEC_ARGS |
| 210 | # undef AUX778076_SEQUENCE_N_ARGS |
| 211 | # undef AUX778076_SEQUENCE_CONVERT_CN_TO |
| 212 | # undef AUX778076_SEQUENCE_N_PARAMS |
| 213 | # undef AUX778076_SEQUENCE_DEFAULT_PARAMS |
| 214 | # undef AUX778076_SEQUENCE_ARGS |
| 215 | # undef AUX778076_SEQUENCE_PARAMS |
| 216 | # undef AUX778076_SEQUENCE_NAME_N |
| 217 | # undef AUX778076_SEQUENCE_DEFAULT |
| 218 | # undef AUX778076_SEQUENCE_TEMPLATE_PARAM |
| 219 | # undef AUX778076_SEQUENCE_PARAM_NAME |
| 220 | # undef AUX778076_SEQUENCE_LIMIT |
| 221 | # undef AUX778076_SEQUENCE_BASE_NAME |
| 222 | # undef AUX778076_SEQUENCE_NAME |
| 223 | # undef AUX778076_SEQUENCE_INTEGRAL_WRAPPER |
| 224 | |
| 225 | }} |
| 226 | |
| 227 | ///// iteration |
| 228 | |
| 229 | #else |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 230 | #define i_ NDNBOOST_PP_FRAME_ITERATION(1) |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 231 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 232 | # if !defined(NDNBOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 233 | |
| 234 | #if i_ == AUX778076_SEQUENCE_LIMIT |
| 235 | |
| 236 | /// primary template (not a specialization!) |
| 237 | template< |
| 238 | AUX778076_SEQUENCE_N_PARAMS(i_) |
| 239 | > |
| 240 | struct AUX778076_SEQUENCE_NAME |
| 241 | : AUX778076_SEQUENCE_NAME_N(i_)< AUX778076_SEQUENCE_N_ARGS(i_) > |
| 242 | { |
| 243 | typedef typename AUX778076_SEQUENCE_NAME_N(i_)< AUX778076_SEQUENCE_N_ARGS(i_) >::type type; |
| 244 | }; |
| 245 | |
| 246 | #else |
| 247 | |
| 248 | template< |
| 249 | AUX778076_SEQUENCE_N_PARAMS(i_) |
| 250 | > |
| 251 | struct AUX778076_SEQUENCE_NAME< AUX778076_SEQUENCE_N_PARTIAL_SPEC_ARGS(i_) > |
| 252 | : AUX778076_SEQUENCE_NAME_N(i_)< AUX778076_SEQUENCE_N_ARGS(i_) > |
| 253 | { |
| 254 | #if i_ > 0 || defined(AUX778076_SEQUENCE_INTEGRAL_WRAPPER) |
| 255 | typedef typename AUX778076_SEQUENCE_NAME_N(i_)< AUX778076_SEQUENCE_N_ARGS(i_) >::type type; |
| 256 | #else |
| 257 | typedef AUX778076_SEQUENCE_NAME_N(i_)< AUX778076_SEQUENCE_N_ARGS(i_) >::type type; |
| 258 | #endif |
| 259 | }; |
| 260 | |
| 261 | #endif // i_ == AUX778076_SEQUENCE_LIMIT |
| 262 | |
| 263 | # else |
| 264 | |
| 265 | namespace aux { |
| 266 | |
| 267 | template<> |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 268 | struct NDNBOOST_PP_CAT(AUX778076_SEQUENCE_NAME,_chooser)<i_> |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 269 | { |
| 270 | template< |
| 271 | AUX778076_SEQUENCE_PARAMS() |
| 272 | > |
| 273 | struct result_ |
| 274 | { |
| 275 | #if i_ > 0 || defined(AUX778076_SEQUENCE_INTEGRAL_WRAPPER) |
| 276 | typedef typename AUX778076_SEQUENCE_NAME_N(i_)< |
| 277 | AUX778076_SEQUENCE_N_ARGS(i_) |
| 278 | >::type type; |
| 279 | #else |
| 280 | typedef AUX778076_SEQUENCE_NAME_N(i_)< |
| 281 | AUX778076_SEQUENCE_N_ARGS(i_) |
| 282 | >::type type; |
| 283 | #endif |
| 284 | }; |
| 285 | }; |
| 286 | |
| 287 | } // namespace aux |
| 288 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 289 | # endif // NDNBOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 290 | |
| 291 | #undef i_ |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 292 | #endif // NDNBOOST_PP_IS_ITERATING |