2 // NO INCLUDE GUARDS, THE HEADER IS INTENDED FOR MULTIPLE INCLUSION
4 #if !defined(BOOST_PP_IS_ITERATING)
8 // Copyright Aleksey Gurtovoy 2000-2008
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)
14 // See http://www.boost.org/libs/mpl for documentation.
16 // $Id: sequence_wrapper.hpp 49271 2008-10-11 06:46:00Z agurtovoy $
17 // $Date: 2008-10-11 02:46:00 -0400 (Sat, 11 Oct 2008) $
20 # include <boost/mpl/aux_/config/ctps.hpp>
21 # include <boost/mpl/aux_/config/static_constant.hpp>
22 # include <boost/mpl/aux_/nttp_decl.hpp>
24 # include <boost/preprocessor/arithmetic/sub.hpp>
25 # include <boost/preprocessor/tuple/elem.hpp>
26 # include <boost/preprocessor/enum_params_with_a_default.hpp>
27 # include <boost/preprocessor/enum_params.hpp>
28 # include <boost/preprocessor/enum.hpp>
29 # include <boost/preprocessor/repeat.hpp>
30 # include <boost/preprocessor/comma_if.hpp>
31 # include <boost/preprocessor/iterate.hpp>
33 #if defined(BOOST_MPL_PREPROCESSING_MODE)
37 namespace boost { namespace mpl {
39 #if !defined(AUX778076_SEQUENCE_BASE_NAME)
40 # define AUX778076_SEQUENCE_BASE_NAME AUX778076_SEQUENCE_NAME
43 #if !defined(AUX778076_SEQUENCE_INTEGRAL_WRAPPER)
45 # define AUX778076_SEQUENCE_PARAM_NAME T
46 # define AUX778076_SEQUENCE_TEMPLATE_PARAM typename T
47 # define AUX778076_SEQUENCE_DEFAULT na
49 # define AUX778076_SEQUENCE_NAME_N(n) \
50 BOOST_PP_CAT(AUX778076_SEQUENCE_BASE_NAME,n) \
53 # define AUX778076_SEQUENCE_PARAMS() \
54 BOOST_PP_ENUM_PARAMS( \
55 AUX778076_SEQUENCE_LIMIT \
56 , AUX778076_SEQUENCE_TEMPLATE_PARAM \
60 # define AUX778076_SEQUENCE_ARGS() \
61 BOOST_PP_ENUM_PARAMS( \
62 AUX778076_SEQUENCE_LIMIT \
67 # define AUX778076_SEQUENCE_DEFAULT_PARAMS() \
68 BOOST_PP_ENUM_PARAMS_WITH_A_DEFAULT( \
69 AUX778076_SEQUENCE_LIMIT \
70 , AUX778076_SEQUENCE_TEMPLATE_PARAM \
71 , AUX778076_SEQUENCE_DEFAULT \
75 # define AUX778076_SEQUENCE_N_PARAMS(n) \
76 BOOST_PP_ENUM_PARAMS(n, AUX778076_SEQUENCE_TEMPLATE_PARAM) \
79 # define AUX778076_SEQUENCE_N_ARGS(n) \
80 BOOST_PP_ENUM_PARAMS(n, T) \
83 # define AUX778076_SEQUENCE_N_PARTIAL_SPEC_ARGS(n) \
84 BOOST_PP_ENUM_PARAMS(n, T) \
85 BOOST_PP_COMMA_IF(n) \
87 BOOST_PP_SUB_D(1,AUX778076_SEQUENCE_LIMIT,n) \
88 , BOOST_PP_TUPLE_ELEM_3_2 \
89 , AUX778076_SEQUENCE_DEFAULT \
93 #else // AUX778076_SEQUENCE_INTEGRAL_WRAPPER
95 # define AUX778076_SEQUENCE_PARAM_NAME C
96 # define AUX778076_SEQUENCE_TEMPLATE_PARAM BOOST_MPL_AUX_NTTP_DECL(long, C)
97 # define AUX778076_SEQUENCE_DEFAULT LONG_MAX
99 # define AUX778076_SEQUENCE_PARAMS() \
100 typename T, BOOST_PP_ENUM_PARAMS( \
101 AUX778076_SEQUENCE_LIMIT \
102 , AUX778076_SEQUENCE_TEMPLATE_PARAM \
106 # define AUX778076_SEQUENCE_ARGS() \
107 T, BOOST_PP_ENUM_PARAMS( \
108 AUX778076_SEQUENCE_LIMIT \
113 # define AUX778076_SEQUENCE_DEFAULT_PARAMS() \
115 BOOST_PP_ENUM_PARAMS_WITH_A_DEFAULT( \
116 AUX778076_SEQUENCE_LIMIT \
117 , AUX778076_SEQUENCE_TEMPLATE_PARAM \
118 , AUX778076_SEQUENCE_DEFAULT \
122 # define AUX778076_SEQUENCE_N_PARAMS(n) \
123 typename T BOOST_PP_COMMA_IF(n) \
124 BOOST_PP_ENUM_PARAMS(n, AUX778076_SEQUENCE_TEMPLATE_PARAM) \
127 # if !defined(AUX778076_SEQUENCE_CONVERT_CN_TO)
128 # define AUX778076_SEQUENCE_CONVERT_CN_TO(z,n,TARGET) BOOST_PP_CAT(C,n)
131 # define AUX778076_SEQUENCE_N_ARGS(n) \
132 T BOOST_PP_COMMA_IF(n) \
133 BOOST_PP_ENUM(n,AUX778076_SEQUENCE_CONVERT_CN_TO,T) \
136 # define AUX778076_SEQUENCE_N_PARTIAL_SPEC_ARGS(n) \
137 T, BOOST_PP_ENUM_PARAMS(n, C) \
138 BOOST_PP_COMMA_IF(n) \
140 BOOST_PP_SUB_D(1,AUX778076_SEQUENCE_LIMIT,n) \
141 , BOOST_PP_TUPLE_ELEM_3_2 \
142 , AUX778076_SEQUENCE_DEFAULT \
146 #endif // AUX778076_SEQUENCE_INTEGRAL_WRAPPER
149 #if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
150 // forward declaration
152 AUX778076_SEQUENCE_DEFAULT_PARAMS()
154 struct AUX778076_SEQUENCE_NAME;
157 template< BOOST_MPL_AUX_NTTP_DECL(int, N) >
158 struct BOOST_PP_CAT(AUX778076_SEQUENCE_NAME,_chooser);
162 #define BOOST_PP_ITERATION_PARAMS_1 \
163 (3,(0, AUX778076_SEQUENCE_LIMIT, <boost/mpl/aux_/sequence_wrapper.hpp>))
164 #include BOOST_PP_ITERATE()
166 // real C++ version is already taken care of
167 #if defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
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 <boost/mpl/aux_/count_args.hpp>
180 AUX778076_SEQUENCE_PARAMS()
182 struct BOOST_PP_CAT(AUX778076_SEQUENCE_NAME,_impl)
184 typedef aux::BOOST_PP_CAT(AUX778076_SEQUENCE_NAME,_count_args)<
185 BOOST_PP_ENUM_PARAMS(AUX778076_SEQUENCE_LIMIT, AUX778076_SEQUENCE_PARAM_NAME)
188 typedef typename aux::BOOST_PP_CAT(AUX778076_SEQUENCE_NAME,_chooser)< arg_num_::value >
189 ::template result_< AUX778076_SEQUENCE_ARGS() >::type type;
195 AUX778076_SEQUENCE_DEFAULT_PARAMS()
197 struct AUX778076_SEQUENCE_NAME
198 : aux::BOOST_PP_CAT(AUX778076_SEQUENCE_NAME,_impl)<
199 AUX778076_SEQUENCE_ARGS()
202 typedef typename aux::BOOST_PP_CAT(AUX778076_SEQUENCE_NAME,_impl)<
203 AUX778076_SEQUENCE_ARGS()
207 #endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
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
230 #define i_ BOOST_PP_FRAME_ITERATION(1)
232 # if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
234 #if i_ == AUX778076_SEQUENCE_LIMIT
236 /// primary template (not a specialization!)
238 AUX778076_SEQUENCE_N_PARAMS(i_)
240 struct AUX778076_SEQUENCE_NAME
241 : AUX778076_SEQUENCE_NAME_N(i_)< AUX778076_SEQUENCE_N_ARGS(i_) >
243 typedef typename AUX778076_SEQUENCE_NAME_N(i_)< AUX778076_SEQUENCE_N_ARGS(i_) >::type type;
249 AUX778076_SEQUENCE_N_PARAMS(i_)
251 struct AUX778076_SEQUENCE_NAME< AUX778076_SEQUENCE_N_PARTIAL_SPEC_ARGS(i_) >
252 : AUX778076_SEQUENCE_NAME_N(i_)< AUX778076_SEQUENCE_N_ARGS(i_) >
254 #if i_ > 0 || defined(AUX778076_SEQUENCE_INTEGRAL_WRAPPER)
255 typedef typename AUX778076_SEQUENCE_NAME_N(i_)< AUX778076_SEQUENCE_N_ARGS(i_) >::type type;
257 typedef AUX778076_SEQUENCE_NAME_N(i_)< AUX778076_SEQUENCE_N_ARGS(i_) >::type type;
261 #endif // i_ == AUX778076_SEQUENCE_LIMIT
268 struct BOOST_PP_CAT(AUX778076_SEQUENCE_NAME,_chooser)<i_>
271 AUX778076_SEQUENCE_PARAMS()
275 #if i_ > 0 || defined(AUX778076_SEQUENCE_INTEGRAL_WRAPPER)
276 typedef typename AUX778076_SEQUENCE_NAME_N(i_)<
277 AUX778076_SEQUENCE_N_ARGS(i_)
280 typedef AUX778076_SEQUENCE_NAME_N(i_)<
281 AUX778076_SEQUENCE_N_ARGS(i_)
289 # endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
292 #endif // BOOST_PP_IS_ITERATING