blob: c2a27542ff38bd14c9ee7ccd53a003bb85356f78 [file] [log] [blame]
Jeff Thompsona28eed82013-08-22 16:21:10 -07001
2// NO INCLUDE GUARDS, THE HEADER IS INTENDED FOR MULTIPLE INCLUSION
3
Jeff Thompson3d613fd2013-10-15 15:39:04 -07004#if !defined(NDNBOOST_PP_IS_ITERATING)
Jeff Thompsona28eed82013-08-22 16:21:10 -07005
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 Thompson3d613fd2013-10-15 15:39:04 -070033#if defined(NDNBOOST_MPL_PREPROCESSING_MODE)
Jeff Thompsona28eed82013-08-22 16:21:10 -070034# undef LONG_MAX
35#endif
36
37namespace 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 Thompson3d613fd2013-10-15 15:39:04 -070050 NDNBOOST_PP_CAT(AUX778076_SEQUENCE_BASE_NAME,n) \
Jeff Thompsona28eed82013-08-22 16:21:10 -070051 /**/
52
53# define AUX778076_SEQUENCE_PARAMS() \
Jeff Thompson3d613fd2013-10-15 15:39:04 -070054 NDNBOOST_PP_ENUM_PARAMS( \
Jeff Thompsona28eed82013-08-22 16:21:10 -070055 AUX778076_SEQUENCE_LIMIT \
56 , AUX778076_SEQUENCE_TEMPLATE_PARAM \
57 ) \
58 /**/
59
60# define AUX778076_SEQUENCE_ARGS() \
Jeff Thompson3d613fd2013-10-15 15:39:04 -070061 NDNBOOST_PP_ENUM_PARAMS( \
Jeff Thompsona28eed82013-08-22 16:21:10 -070062 AUX778076_SEQUENCE_LIMIT \
63 , T \
64 ) \
65 /**/
66
67# define AUX778076_SEQUENCE_DEFAULT_PARAMS() \
Jeff Thompson3d613fd2013-10-15 15:39:04 -070068 NDNBOOST_PP_ENUM_PARAMS_WITH_A_DEFAULT( \
Jeff Thompsona28eed82013-08-22 16:21:10 -070069 AUX778076_SEQUENCE_LIMIT \
70 , AUX778076_SEQUENCE_TEMPLATE_PARAM \
71 , AUX778076_SEQUENCE_DEFAULT \
72 ) \
73 /**/
74
75# define AUX778076_SEQUENCE_N_PARAMS(n) \
Jeff Thompson3d613fd2013-10-15 15:39:04 -070076 NDNBOOST_PP_ENUM_PARAMS(n, AUX778076_SEQUENCE_TEMPLATE_PARAM) \
Jeff Thompsona28eed82013-08-22 16:21:10 -070077 /**/
78
79# define AUX778076_SEQUENCE_N_ARGS(n) \
Jeff Thompson3d613fd2013-10-15 15:39:04 -070080 NDNBOOST_PP_ENUM_PARAMS(n, T) \
Jeff Thompsona28eed82013-08-22 16:21:10 -070081 /**/
82
83# define AUX778076_SEQUENCE_N_PARTIAL_SPEC_ARGS(n) \
Jeff Thompson3d613fd2013-10-15 15:39:04 -070084 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 Thompsona28eed82013-08-22 16:21:10 -070089 , AUX778076_SEQUENCE_DEFAULT \
90 ) \
91 /**/
92
93#else // AUX778076_SEQUENCE_INTEGRAL_WRAPPER
94
95# define AUX778076_SEQUENCE_PARAM_NAME C
Jeff Thompson3d613fd2013-10-15 15:39:04 -070096# define AUX778076_SEQUENCE_TEMPLATE_PARAM NDNBOOST_MPL_AUX_NTTP_DECL(long, C)
Jeff Thompsona28eed82013-08-22 16:21:10 -070097# define AUX778076_SEQUENCE_DEFAULT LONG_MAX
98
99# define AUX778076_SEQUENCE_PARAMS() \
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700100 typename T, NDNBOOST_PP_ENUM_PARAMS( \
Jeff Thompsona28eed82013-08-22 16:21:10 -0700101 AUX778076_SEQUENCE_LIMIT \
102 , AUX778076_SEQUENCE_TEMPLATE_PARAM \
103 ) \
104 /**/
105
106# define AUX778076_SEQUENCE_ARGS() \
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700107 T, NDNBOOST_PP_ENUM_PARAMS( \
Jeff Thompsona28eed82013-08-22 16:21:10 -0700108 AUX778076_SEQUENCE_LIMIT \
109 , C \
110 ) \
111 /**/
112
113# define AUX778076_SEQUENCE_DEFAULT_PARAMS() \
114 typename T, \
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700115 NDNBOOST_PP_ENUM_PARAMS_WITH_A_DEFAULT( \
Jeff Thompsona28eed82013-08-22 16:21:10 -0700116 AUX778076_SEQUENCE_LIMIT \
117 , AUX778076_SEQUENCE_TEMPLATE_PARAM \
118 , AUX778076_SEQUENCE_DEFAULT \
119 ) \
120 /**/
121
122# define AUX778076_SEQUENCE_N_PARAMS(n) \
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700123 typename T NDNBOOST_PP_COMMA_IF(n) \
124 NDNBOOST_PP_ENUM_PARAMS(n, AUX778076_SEQUENCE_TEMPLATE_PARAM) \
Jeff Thompsona28eed82013-08-22 16:21:10 -0700125 /**/
126
127# if !defined(AUX778076_SEQUENCE_CONVERT_CN_TO)
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700128# define AUX778076_SEQUENCE_CONVERT_CN_TO(z,n,TARGET) NDNBOOST_PP_CAT(C,n)
Jeff Thompsona28eed82013-08-22 16:21:10 -0700129# endif
130
131# define AUX778076_SEQUENCE_N_ARGS(n) \
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700132 T NDNBOOST_PP_COMMA_IF(n) \
133 NDNBOOST_PP_ENUM(n,AUX778076_SEQUENCE_CONVERT_CN_TO,T) \
Jeff Thompsona28eed82013-08-22 16:21:10 -0700134 /**/
135
136# define AUX778076_SEQUENCE_N_PARTIAL_SPEC_ARGS(n) \
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700137 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 Thompsona28eed82013-08-22 16:21:10 -0700142 , AUX778076_SEQUENCE_DEFAULT \
143 ) \
144 /**/
145
146#endif // AUX778076_SEQUENCE_INTEGRAL_WRAPPER
147
148
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700149#if !defined(NDNBOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
Jeff Thompsona28eed82013-08-22 16:21:10 -0700150// forward declaration
151template<
152 AUX778076_SEQUENCE_DEFAULT_PARAMS()
153 >
154struct AUX778076_SEQUENCE_NAME;
155#else
156namespace aux {
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700157template< NDNBOOST_MPL_AUX_NTTP_DECL(int, N) >
158struct NDNBOOST_PP_CAT(AUX778076_SEQUENCE_NAME,_chooser);
Jeff Thompsona28eed82013-08-22 16:21:10 -0700159}
160#endif
161
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700162#define NDNBOOST_PP_ITERATION_PARAMS_1 \
Jeff Thompsona28eed82013-08-22 16:21:10 -0700163 (3,(0, AUX778076_SEQUENCE_LIMIT, <ndnboost/mpl/aux_/sequence_wrapper.hpp>))
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700164#include NDNBOOST_PP_ITERATE()
Jeff Thompsona28eed82013-08-22 16:21:10 -0700165
166// real C++ version is already taken care of
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700167#if defined(NDNBOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
Jeff Thompsona28eed82013-08-22 16:21:10 -0700168
169namespace 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
179template<
180 AUX778076_SEQUENCE_PARAMS()
181 >
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700182struct NDNBOOST_PP_CAT(AUX778076_SEQUENCE_NAME,_impl)
Jeff Thompsona28eed82013-08-22 16:21:10 -0700183{
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700184 typedef aux::NDNBOOST_PP_CAT(AUX778076_SEQUENCE_NAME,_count_args)<
185 NDNBOOST_PP_ENUM_PARAMS(AUX778076_SEQUENCE_LIMIT, AUX778076_SEQUENCE_PARAM_NAME)
Jeff Thompsona28eed82013-08-22 16:21:10 -0700186 > arg_num_;
187
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700188 typedef typename aux::NDNBOOST_PP_CAT(AUX778076_SEQUENCE_NAME,_chooser)< arg_num_::value >
Jeff Thompsona28eed82013-08-22 16:21:10 -0700189 ::template result_< AUX778076_SEQUENCE_ARGS() >::type type;
190};
191
192} // namespace aux
193
194template<
195 AUX778076_SEQUENCE_DEFAULT_PARAMS()
196 >
197struct AUX778076_SEQUENCE_NAME
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700198 : aux::NDNBOOST_PP_CAT(AUX778076_SEQUENCE_NAME,_impl)<
Jeff Thompsona28eed82013-08-22 16:21:10 -0700199 AUX778076_SEQUENCE_ARGS()
200 >::type
201{
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700202 typedef typename aux::NDNBOOST_PP_CAT(AUX778076_SEQUENCE_NAME,_impl)<
Jeff Thompsona28eed82013-08-22 16:21:10 -0700203 AUX778076_SEQUENCE_ARGS()
204 >::type type;
205};
206
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700207#endif // NDNBOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
Jeff Thompsona28eed82013-08-22 16:21:10 -0700208
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 Thompson3d613fd2013-10-15 15:39:04 -0700230#define i_ NDNBOOST_PP_FRAME_ITERATION(1)
Jeff Thompsona28eed82013-08-22 16:21:10 -0700231
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700232# if !defined(NDNBOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
Jeff Thompsona28eed82013-08-22 16:21:10 -0700233
234#if i_ == AUX778076_SEQUENCE_LIMIT
235
236/// primary template (not a specialization!)
237template<
238 AUX778076_SEQUENCE_N_PARAMS(i_)
239 >
240struct 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
248template<
249 AUX778076_SEQUENCE_N_PARAMS(i_)
250 >
251struct 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
265namespace aux {
266
267template<>
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700268struct NDNBOOST_PP_CAT(AUX778076_SEQUENCE_NAME,_chooser)<i_>
Jeff Thompsona28eed82013-08-22 16:21:10 -0700269{
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 Thompson3d613fd2013-10-15 15:39:04 -0700289# endif // NDNBOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
Jeff Thompsona28eed82013-08-22 16:21:10 -0700290
291#undef i_
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700292#endif // NDNBOOST_PP_IS_ITERATING