• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 
2 // NO INCLUDE GUARDS, THE HEADER IS INTENDED FOR MULTIPLE INCLUSION
3 
4 #if !defined(BOOST_PP_IS_ITERATING)
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$
17 // $Date$
18 // $Revision$
19 
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>
23 
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>
32 
33 #if defined(BOOST_MPL_PREPROCESSING_MODE)
34 #   undef LONG_MAX
35 #endif
36 
37 namespace boost { 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) \
50     BOOST_PP_CAT(AUX778076_SEQUENCE_BASE_NAME,n) \
51     /**/
52 
53 #   define AUX778076_SEQUENCE_PARAMS() \
54     BOOST_PP_ENUM_PARAMS( \
55           AUX778076_SEQUENCE_LIMIT \
56         , AUX778076_SEQUENCE_TEMPLATE_PARAM \
57         ) \
58     /**/
59 
60 #   define AUX778076_SEQUENCE_ARGS() \
61     BOOST_PP_ENUM_PARAMS( \
62           AUX778076_SEQUENCE_LIMIT \
63         , T \
64         ) \
65     /**/
66 
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 \
72         ) \
73     /**/
74 
75 #   define AUX778076_SEQUENCE_N_PARAMS(n) \
76     BOOST_PP_ENUM_PARAMS(n, AUX778076_SEQUENCE_TEMPLATE_PARAM) \
77     /**/
78 
79 #   define AUX778076_SEQUENCE_N_ARGS(n) \
80     BOOST_PP_ENUM_PARAMS(n, T) \
81     /**/
82 
83 #   define AUX778076_SEQUENCE_N_PARTIAL_SPEC_ARGS(n) \
84     BOOST_PP_ENUM_PARAMS(n, T) \
85     BOOST_PP_COMMA_IF(n) \
86     BOOST_PP_ENUM( \
87           BOOST_PP_SUB_D(1,AUX778076_SEQUENCE_LIMIT,n) \
88         , BOOST_PP_TUPLE_ELEM_3_2 \
89         , AUX778076_SEQUENCE_DEFAULT \
90         ) \
91     /**/
92 
93 #else // AUX778076_SEQUENCE_INTEGRAL_WRAPPER
94 
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
98 
99 #   define AUX778076_SEQUENCE_PARAMS() \
100     typename T, BOOST_PP_ENUM_PARAMS( \
101           AUX778076_SEQUENCE_LIMIT \
102         , AUX778076_SEQUENCE_TEMPLATE_PARAM \
103         ) \
104     /**/
105 
106 #   define AUX778076_SEQUENCE_ARGS() \
107     T, BOOST_PP_ENUM_PARAMS( \
108           AUX778076_SEQUENCE_LIMIT \
109         , C \
110         ) \
111     /**/
112 
113 #   define AUX778076_SEQUENCE_DEFAULT_PARAMS() \
114     typename T, \
115     BOOST_PP_ENUM_PARAMS_WITH_A_DEFAULT( \
116           AUX778076_SEQUENCE_LIMIT \
117         , AUX778076_SEQUENCE_TEMPLATE_PARAM \
118         , AUX778076_SEQUENCE_DEFAULT \
119         ) \
120     /**/
121 
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) \
125     /**/
126 
127 #   if !defined(AUX778076_SEQUENCE_CONVERT_CN_TO)
128 #       define AUX778076_SEQUENCE_CONVERT_CN_TO(z,n,TARGET) BOOST_PP_CAT(C,n)
129 #   endif
130 
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) \
134     /**/
135 
136 #   define AUX778076_SEQUENCE_N_PARTIAL_SPEC_ARGS(n) \
137     T, BOOST_PP_ENUM_PARAMS(n, C) \
138     BOOST_PP_COMMA_IF(n) \
139     BOOST_PP_ENUM( \
140           BOOST_PP_SUB_D(1,AUX778076_SEQUENCE_LIMIT,n) \
141         , BOOST_PP_TUPLE_ELEM_3_2 \
142         , AUX778076_SEQUENCE_DEFAULT \
143         ) \
144     /**/
145 
146 #endif // AUX778076_SEQUENCE_INTEGRAL_WRAPPER
147 
148 
149 #if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
150 // forward declaration
151 template<
152       AUX778076_SEQUENCE_DEFAULT_PARAMS()
153     >
154 struct AUX778076_SEQUENCE_NAME;
155 #else
156 namespace aux {
157 template< BOOST_MPL_AUX_NTTP_DECL(int, N) >
158 struct BOOST_PP_CAT(AUX778076_SEQUENCE_NAME,_chooser);
159 }
160 #endif
161 
162 #define BOOST_PP_ITERATION_PARAMS_1 \
163     (3,(0, AUX778076_SEQUENCE_LIMIT, <boost/mpl/aux_/sequence_wrapper.hpp>))
164 #include BOOST_PP_ITERATE()
165 
166 // real C++ version is already taken care of
167 #if defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
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 <boost/mpl/aux_/count_args.hpp>
178 
179 template<
180       AUX778076_SEQUENCE_PARAMS()
181     >
BOOST_PP_CAT(AUX778076_SEQUENCE_NAME,_impl)182 struct BOOST_PP_CAT(AUX778076_SEQUENCE_NAME,_impl)
183 {
184     typedef aux::BOOST_PP_CAT(AUX778076_SEQUENCE_NAME,_count_args)<
185           BOOST_PP_ENUM_PARAMS(AUX778076_SEQUENCE_LIMIT, AUX778076_SEQUENCE_PARAM_NAME)
186         > arg_num_;
187 
188     typedef typename aux::BOOST_PP_CAT(AUX778076_SEQUENCE_NAME,_chooser)< arg_num_::value >
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
198     : aux::BOOST_PP_CAT(AUX778076_SEQUENCE_NAME,_impl)<
199           AUX778076_SEQUENCE_ARGS()
200         >::type
201 {
202     typedef typename aux::BOOST_PP_CAT(AUX778076_SEQUENCE_NAME,_impl)<
203           AUX778076_SEQUENCE_ARGS()
204         >::type type;
205 };
206 
207 #endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
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
230 #define i_ BOOST_PP_FRAME_ITERATION(1)
231 
232 #   if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
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<>
BOOST_PP_CAT(AUX778076_SEQUENCE_NAME,_chooser)268 struct BOOST_PP_CAT(AUX778076_SEQUENCE_NAME,_chooser)<i_>
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 
289 #   endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
290 
291 #undef i_
292 #endif // BOOST_PP_IS_ITERATING
293