blob: 07bf5646f8d07caaff5c7de769f0f10d6f84d889 [file] [log] [blame]
Jeff Thompsona28eed82013-08-22 16:21:10 -07001
Jeff Thompson3d613fd2013-10-15 15:39:04 -07002#if !defined(NDNBOOST_PP_IS_ITERATING)
Jeff Thompsona28eed82013-08-22 16:21:10 -07003
4///// header body
5
6// NO INCLUDE GUARDS, THE HEADER IS INTENDED FOR MULTIPLE INCLUSION!
7
8// Copyright Aleksey Gurtovoy 2000-2004
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: numeric_op.hpp 49267 2008-10-11 06:19:02Z agurtovoy $
17// $Date: 2008-10-10 23:19:02 -0700 (Fri, 10 Oct 2008) $
18// $Revision: 49267 $
19
Jeff Thompson3d613fd2013-10-15 15:39:04 -070020#if !defined(NDNBOOST_MPL_PREPROCESSING_MODE)
Jeff Thompsona28eed82013-08-22 16:21:10 -070021# include <ndnboost/mpl/numeric_cast.hpp>
22# include <ndnboost/mpl/apply_wrap.hpp>
23# include <ndnboost/mpl/if.hpp>
24# include <ndnboost/mpl/tag.hpp>
25# include <ndnboost/mpl/aux_/numeric_cast_utils.hpp>
26# include <ndnboost/mpl/aux_/na.hpp>
27# include <ndnboost/mpl/aux_/na_spec.hpp>
28# include <ndnboost/mpl/aux_/lambda_support.hpp>
29# include <ndnboost/mpl/aux_/msvc_eti_base.hpp>
30# include <ndnboost/mpl/aux_/value_wknd.hpp>
31# include <ndnboost/mpl/aux_/config/eti.hpp>
32# include <ndnboost/mpl/aux_/nttp_decl.hpp>
33#endif
34
35#include <ndnboost/mpl/aux_/config/static_constant.hpp>
36
Jeff Thompson3d613fd2013-10-15 15:39:04 -070037#if defined(NDNBOOST_MPL_CFG_NO_PREPROCESSED_HEADERS) \
38 || defined(NDNBOOST_MPL_PREPROCESSING_MODE)
Jeff Thompsona28eed82013-08-22 16:21:10 -070039
40# include <ndnboost/mpl/limits/arity.hpp>
41# include <ndnboost/mpl/aux_/preprocessor/partial_spec_params.hpp>
42# include <ndnboost/mpl/aux_/preprocessor/def_params_tail.hpp>
43# include <ndnboost/mpl/aux_/preprocessor/repeat.hpp>
44# include <ndnboost/mpl/aux_/preprocessor/ext_params.hpp>
45# include <ndnboost/mpl/aux_/preprocessor/params.hpp>
46# include <ndnboost/mpl/aux_/preprocessor/enum.hpp>
47# include <ndnboost/mpl/aux_/preprocessor/add.hpp>
48# include <ndnboost/mpl/aux_/preprocessor/sub.hpp>
49# include <ndnboost/mpl/aux_/config/ctps.hpp>
50# include <ndnboost/mpl/aux_/config/eti.hpp>
51# include <ndnboost/mpl/aux_/config/msvc.hpp>
52# include <ndnboost/mpl/aux_/config/workaround.hpp>
53
54# include <ndnboost/preprocessor/dec.hpp>
55# include <ndnboost/preprocessor/inc.hpp>
56# include <ndnboost/preprocessor/iterate.hpp>
57# include <ndnboost/preprocessor/cat.hpp>
58
59
60#if !defined(AUX778076_OP_ARITY)
Jeff Thompson3d613fd2013-10-15 15:39:04 -070061# define AUX778076_OP_ARITY NDNBOOST_MPL_LIMIT_METAFUNCTION_ARITY
Jeff Thompsona28eed82013-08-22 16:21:10 -070062#endif
63
64#if !defined(AUX778076_OP_IMPL_NAME)
Jeff Thompson3d613fd2013-10-15 15:39:04 -070065# define AUX778076_OP_IMPL_NAME NDNBOOST_PP_CAT(AUX778076_OP_PREFIX,_impl)
Jeff Thompsona28eed82013-08-22 16:21:10 -070066#endif
67
68#if !defined(AUX778076_OP_TAG_NAME)
Jeff Thompson3d613fd2013-10-15 15:39:04 -070069# define AUX778076_OP_TAG_NAME NDNBOOST_PP_CAT(AUX778076_OP_PREFIX,_tag)
Jeff Thompsona28eed82013-08-22 16:21:10 -070070#endif
71
72namespace ndnboost { namespace mpl {
73
74template<
75 typename Tag1
76 , typename Tag2
Jeff Thompson3d613fd2013-10-15 15:39:04 -070077#if NDNBOOST_WORKAROUND(NDNBOOST_MSVC, <= 1300)
78 , NDNBOOST_MPL_AUX_NTTP_DECL(int, tag1_) = NDNBOOST_MPL_AUX_MSVC_VALUE_WKND(Tag1)::value
79 , NDNBOOST_MPL_AUX_NTTP_DECL(int, tag2_) = NDNBOOST_MPL_AUX_MSVC_VALUE_WKND(Tag2)::value
Jeff Thompsona28eed82013-08-22 16:21:10 -070080 >
81struct AUX778076_OP_IMPL_NAME
82 : if_c<
83 ( tag1_ > tag2_ )
84#else
85 >
86struct AUX778076_OP_IMPL_NAME
87 : if_c<
Jeff Thompson3d613fd2013-10-15 15:39:04 -070088 ( NDNBOOST_MPL_AUX_NESTED_VALUE_WKND(int, Tag1)
89 > NDNBOOST_MPL_AUX_NESTED_VALUE_WKND(int, Tag2)
Jeff Thompsona28eed82013-08-22 16:21:10 -070090 )
91#endif
92 , aux::cast2nd_impl< AUX778076_OP_IMPL_NAME<Tag1,Tag1>,Tag1,Tag2 >
93 , aux::cast1st_impl< AUX778076_OP_IMPL_NAME<Tag2,Tag2>,Tag1,Tag2 >
94 >::type
95{
96};
97
98/// for Digital Mars C++/compilers with no CTPS/TTP support
99template<> struct AUX778076_OP_IMPL_NAME<na,na>
100{
101 template< typename U1, typename U2 > struct apply
102 {
103 typedef apply type;
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700104 NDNBOOST_STATIC_CONSTANT(int, value = 0);
Jeff Thompsona28eed82013-08-22 16:21:10 -0700105 };
106};
107
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700108#if !defined(NDNBOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
Jeff Thompsona28eed82013-08-22 16:21:10 -0700109template< typename Tag > struct AUX778076_OP_IMPL_NAME<na,Tag>
110{
111 template< typename U1, typename U2 > struct apply
112 {
113 typedef apply type;
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700114 NDNBOOST_STATIC_CONSTANT(int, value = 0);
Jeff Thompsona28eed82013-08-22 16:21:10 -0700115 };
116};
117
118template< typename Tag > struct AUX778076_OP_IMPL_NAME<Tag,na>
119{
120 template< typename U1, typename U2 > struct apply
121 {
122 typedef apply type;
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700123 NDNBOOST_STATIC_CONSTANT(int, value = 0);
Jeff Thompsona28eed82013-08-22 16:21:10 -0700124 };
125};
126#else
127template<> struct AUX778076_OP_IMPL_NAME<na,integral_c_tag>
128{
129 template< typename U1, typename U2 > struct apply
130 {
131 typedef apply type;
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700132 NDNBOOST_STATIC_CONSTANT(int, value = 0);
Jeff Thompsona28eed82013-08-22 16:21:10 -0700133 };
134};
135
136template<> struct AUX778076_OP_IMPL_NAME<integral_c_tag,na>
137{
138 template< typename U1, typename U2 > struct apply
139 {
140 typedef apply type;
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700141 NDNBOOST_STATIC_CONSTANT(int, value = 0);
Jeff Thompsona28eed82013-08-22 16:21:10 -0700142 };
143};
144#endif
145
146
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700147#if defined(NDNBOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) \
148 && NDNBOOST_WORKAROUND(NDNBOOST_MSVC, >= 1300)
Jeff Thompsona28eed82013-08-22 16:21:10 -0700149template< typename T > struct AUX778076_OP_TAG_NAME
150 : tag<T,na>
151{
152};
153#else
154template< typename T > struct AUX778076_OP_TAG_NAME
155{
156 typedef typename T::tag type;
157};
158#endif
159
160
161#if AUX778076_OP_ARITY != 2
162
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700163# if !defined(NDNBOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
Jeff Thompsona28eed82013-08-22 16:21:10 -0700164
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700165# define AUX778076_OP_RIGHT_OPERAND(unused, i, N) , NDNBOOST_PP_CAT(N, NDNBOOST_MPL_PP_ADD(i, 2))>
Jeff Thompsona28eed82013-08-22 16:21:10 -0700166# define AUX778076_OP_N_CALLS(i, N) \
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700167 NDNBOOST_MPL_PP_REPEAT( NDNBOOST_PP_DEC(i), NDNBOOST_MPL_PP_REPEAT_IDENTITY_FUNC, AUX778076_OP_NAME< ) \
168 N1 NDNBOOST_MPL_PP_REPEAT( NDNBOOST_MPL_PP_SUB(i, 1), AUX778076_OP_RIGHT_OPERAND, N ) \
Jeff Thompsona28eed82013-08-22 16:21:10 -0700169/**/
170
171template<
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700172 typename NDNBOOST_MPL_AUX_NA_PARAM(N1)
173 , typename NDNBOOST_MPL_AUX_NA_PARAM(N2)
174 NDNBOOST_MPL_PP_DEF_PARAMS_TAIL(2, typename N, na)
Jeff Thompsona28eed82013-08-22 16:21:10 -0700175 >
176struct AUX778076_OP_NAME
177 : AUX778076_OP_N_CALLS(AUX778076_OP_ARITY, N)
178{
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700179 NDNBOOST_MPL_AUX_LAMBDA_SUPPORT(
Jeff Thompsona28eed82013-08-22 16:21:10 -0700180 AUX778076_OP_ARITY
181 , AUX778076_OP_NAME
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700182 , ( NDNBOOST_MPL_PP_PARAMS(AUX778076_OP_ARITY, N) )
Jeff Thompsona28eed82013-08-22 16:21:10 -0700183 )
184};
185
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700186#define NDNBOOST_PP_ITERATION_PARAMS_1 \
187 (3,( NDNBOOST_PP_DEC(AUX778076_OP_ARITY), 2, <ndnboost/mpl/aux_/numeric_op.hpp> ))
188#include NDNBOOST_PP_ITERATE()
Jeff Thompsona28eed82013-08-22 16:21:10 -0700189
190# undef AUX778076_OP_N_CALLS
191# undef AUX778076_OP_RIGHT_OPERAND
192
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700193# else // NDNBOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
Jeff Thompsona28eed82013-08-22 16:21:10 -0700194
195/// forward declaration
196template<
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700197 typename NDNBOOST_MPL_AUX_NA_PARAM(N1)
198 , typename NDNBOOST_MPL_AUX_NA_PARAM(N2)
Jeff Thompsona28eed82013-08-22 16:21:10 -0700199 >
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700200struct NDNBOOST_PP_CAT(AUX778076_OP_NAME,2);
Jeff Thompsona28eed82013-08-22 16:21:10 -0700201
202template<
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700203 typename NDNBOOST_MPL_AUX_NA_PARAM(N1)
204 , typename NDNBOOST_MPL_AUX_NA_PARAM(N2)
205 NDNBOOST_MPL_PP_DEF_PARAMS_TAIL(2, typename N, na)
Jeff Thompsona28eed82013-08-22 16:21:10 -0700206 >
207struct AUX778076_OP_NAME
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700208#if NDNBOOST_WORKAROUND(NDNBOOST_MSVC, == 1300)
Jeff Thompsona28eed82013-08-22 16:21:10 -0700209 : aux::msvc_eti_base< typename if_<
210#else
211 : if_<
212#endif
213 is_na<N3>
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700214 , NDNBOOST_PP_CAT(AUX778076_OP_NAME,2)<N1,N2>
Jeff Thompsona28eed82013-08-22 16:21:10 -0700215 , AUX778076_OP_NAME<
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700216 NDNBOOST_PP_CAT(AUX778076_OP_NAME,2)<N1,N2>
217 , NDNBOOST_MPL_PP_EXT_PARAMS(3, NDNBOOST_PP_INC(AUX778076_OP_ARITY), N)
Jeff Thompsona28eed82013-08-22 16:21:10 -0700218 >
219 >::type
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700220#if NDNBOOST_WORKAROUND(NDNBOOST_MSVC, == 1300)
Jeff Thompsona28eed82013-08-22 16:21:10 -0700221 >
222#endif
223{
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700224 NDNBOOST_MPL_AUX_LAMBDA_SUPPORT(
Jeff Thompsona28eed82013-08-22 16:21:10 -0700225 AUX778076_OP_ARITY
226 , AUX778076_OP_NAME
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700227 , ( NDNBOOST_MPL_PP_PARAMS(AUX778076_OP_ARITY, N) )
Jeff Thompsona28eed82013-08-22 16:21:10 -0700228 )
229};
230
231template<
232 typename N1
233 , typename N2
234 >
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700235struct NDNBOOST_PP_CAT(AUX778076_OP_NAME,2)
Jeff Thompsona28eed82013-08-22 16:21:10 -0700236
237#endif
238
239#else // AUX778076_OP_ARITY == 2
240
241template<
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700242 typename NDNBOOST_MPL_AUX_NA_PARAM(N1)
243 , typename NDNBOOST_MPL_AUX_NA_PARAM(N2)
Jeff Thompsona28eed82013-08-22 16:21:10 -0700244 >
245struct AUX778076_OP_NAME
246
247#endif
248
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700249#if !defined(NDNBOOST_MPL_CFG_MSVC_ETI_BUG)
Jeff Thompsona28eed82013-08-22 16:21:10 -0700250 : AUX778076_OP_IMPL_NAME<
251 typename AUX778076_OP_TAG_NAME<N1>::type
252 , typename AUX778076_OP_TAG_NAME<N2>::type
253 >::template apply<N1,N2>::type
254#else
255 : aux::msvc_eti_base< typename apply_wrap2<
256 AUX778076_OP_IMPL_NAME<
257 typename AUX778076_OP_TAG_NAME<N1>::type
258 , typename AUX778076_OP_TAG_NAME<N2>::type
259 >
260 , N1
261 , N2
262 >::type >::type
263#endif
264{
265#if AUX778076_OP_ARITY != 2
266
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700267# if !defined(NDNBOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
268 NDNBOOST_MPL_AUX_LAMBDA_SUPPORT_SPEC(
Jeff Thompsona28eed82013-08-22 16:21:10 -0700269 AUX778076_OP_ARITY
270 , AUX778076_OP_NAME
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700271 , ( NDNBOOST_MPL_PP_PARTIAL_SPEC_PARAMS(2, N, na) )
Jeff Thompsona28eed82013-08-22 16:21:10 -0700272 )
273# else
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700274 NDNBOOST_MPL_AUX_LAMBDA_SUPPORT(2, NDNBOOST_PP_CAT(AUX778076_OP_NAME,2), (N1, N2))
Jeff Thompsona28eed82013-08-22 16:21:10 -0700275# endif
276
277#else
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700278 NDNBOOST_MPL_AUX_LAMBDA_SUPPORT(2, AUX778076_OP_NAME, (N1, N2))
Jeff Thompsona28eed82013-08-22 16:21:10 -0700279#endif
280};
281
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700282NDNBOOST_MPL_AUX_NA_SPEC2(2, AUX778076_OP_ARITY, AUX778076_OP_NAME)
Jeff Thompsona28eed82013-08-22 16:21:10 -0700283
284}}
285
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700286#endif // NDNBOOST_MPL_CFG_NO_PREPROCESSED_HEADERS
Jeff Thompsona28eed82013-08-22 16:21:10 -0700287
288///// iteration, depth == 1
289
290// For gcc 4.4 compatability, we must include the
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700291// NDNBOOST_PP_ITERATION_DEPTH test inside an #else clause.
292#else // NDNBOOST_PP_IS_ITERATING
293#if NDNBOOST_PP_ITERATION_DEPTH() == 1
Jeff Thompsona28eed82013-08-22 16:21:10 -0700294
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700295# define i_ NDNBOOST_PP_FRAME_ITERATION(1)
Jeff Thompsona28eed82013-08-22 16:21:10 -0700296
297template<
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700298 NDNBOOST_MPL_PP_PARAMS(i_, typename N)
Jeff Thompsona28eed82013-08-22 16:21:10 -0700299 >
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700300struct AUX778076_OP_NAME<NDNBOOST_MPL_PP_PARTIAL_SPEC_PARAMS(i_, N, na)>
Jeff Thompsona28eed82013-08-22 16:21:10 -0700301#if i_ != 2
302 : AUX778076_OP_N_CALLS(i_, N)
303{
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700304 NDNBOOST_MPL_AUX_LAMBDA_SUPPORT_SPEC(
Jeff Thompsona28eed82013-08-22 16:21:10 -0700305 AUX778076_OP_ARITY
306 , AUX778076_OP_NAME
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700307 , ( NDNBOOST_MPL_PP_PARTIAL_SPEC_PARAMS(i_, N, na) )
Jeff Thompsona28eed82013-08-22 16:21:10 -0700308 )
309};
310#endif
311
312# undef i_
313
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700314#endif // NDNBOOST_PP_ITERATION_DEPTH()
315#endif // NDNBOOST_PP_IS_ITERATING