2 #if !defined(BOOST_PP_IS_ITERATING)
\r
6 // NO INCLUDE GUARDS, THE HEADER IS INTENDED FOR MULTIPLE INCLUSION!
\r
8 // Copyright Aleksey Gurtovoy 2000-2004
\r
10 // Distributed under the Boost Software License, Version 1.0.
\r
11 // (See accompanying file LICENSE_1_0.txt or copy at
\r
12 // http://www.boost.org/LICENSE_1_0.txt)
\r
14 // See http://www.boost.org/libs/mpl for documentation.
\r
16 // $Id: numeric_op.hpp 49267 2008-10-11 06:19:02Z agurtovoy $
\r
17 // $Date: 2008-10-11 02:19:02 -0400 (Sat, 11 Oct 2008) $
\r
18 // $Revision: 49267 $
\r
20 #if !defined(BOOST_MPL_PREPROCESSING_MODE)
\r
21 # include <boost/mpl/numeric_cast.hpp>
\r
22 # include <boost/mpl/apply_wrap.hpp>
\r
23 # include <boost/mpl/if.hpp>
\r
24 # include <boost/mpl/tag.hpp>
\r
25 # include <boost/mpl/aux_/numeric_cast_utils.hpp>
\r
26 # include <boost/mpl/aux_/na.hpp>
\r
27 # include <boost/mpl/aux_/na_spec.hpp>
\r
28 # include <boost/mpl/aux_/lambda_support.hpp>
\r
29 # include <boost/mpl/aux_/msvc_eti_base.hpp>
\r
30 # include <boost/mpl/aux_/value_wknd.hpp>
\r
31 # include <boost/mpl/aux_/config/eti.hpp>
\r
32 # include <boost/mpl/aux_/nttp_decl.hpp>
\r
35 #include <boost/mpl/aux_/config/static_constant.hpp>
\r
37 #if defined(BOOST_MPL_CFG_NO_PREPROCESSED_HEADERS) \
\r
38 || defined(BOOST_MPL_PREPROCESSING_MODE)
\r
40 # include <boost/mpl/limits/arity.hpp>
\r
41 # include <boost/mpl/aux_/preprocessor/partial_spec_params.hpp>
\r
42 # include <boost/mpl/aux_/preprocessor/def_params_tail.hpp>
\r
43 # include <boost/mpl/aux_/preprocessor/repeat.hpp>
\r
44 # include <boost/mpl/aux_/preprocessor/ext_params.hpp>
\r
45 # include <boost/mpl/aux_/preprocessor/params.hpp>
\r
46 # include <boost/mpl/aux_/preprocessor/enum.hpp>
\r
47 # include <boost/mpl/aux_/preprocessor/add.hpp>
\r
48 # include <boost/mpl/aux_/preprocessor/sub.hpp>
\r
49 # include <boost/mpl/aux_/config/ctps.hpp>
\r
50 # include <boost/mpl/aux_/config/eti.hpp>
\r
51 # include <boost/mpl/aux_/config/msvc.hpp>
\r
52 # include <boost/mpl/aux_/config/workaround.hpp>
\r
54 # include <boost/preprocessor/dec.hpp>
\r
55 # include <boost/preprocessor/inc.hpp>
\r
56 # include <boost/preprocessor/iterate.hpp>
\r
57 # include <boost/preprocessor/cat.hpp>
\r
60 #if !defined(AUX778076_OP_ARITY)
\r
61 # define AUX778076_OP_ARITY BOOST_MPL_LIMIT_METAFUNCTION_ARITY
\r
64 #if !defined(AUX778076_OP_IMPL_NAME)
\r
65 # define AUX778076_OP_IMPL_NAME BOOST_PP_CAT(AUX778076_OP_PREFIX,_impl)
\r
68 #if !defined(AUX778076_OP_TAG_NAME)
\r
69 # define AUX778076_OP_TAG_NAME BOOST_PP_CAT(AUX778076_OP_PREFIX,_tag)
\r
72 namespace boost { namespace mpl {
\r
77 #if BOOST_WORKAROUND(BOOST_MSVC, <= 1300)
\r
78 , BOOST_MPL_AUX_NTTP_DECL(int, tag1_) = BOOST_MPL_AUX_MSVC_VALUE_WKND(Tag1)::value
\r
79 , BOOST_MPL_AUX_NTTP_DECL(int, tag2_) = BOOST_MPL_AUX_MSVC_VALUE_WKND(Tag2)::value
\r
81 struct AUX778076_OP_IMPL_NAME
\r
86 struct AUX778076_OP_IMPL_NAME
\r
88 ( BOOST_MPL_AUX_NESTED_VALUE_WKND(int, Tag1)
\r
89 > BOOST_MPL_AUX_NESTED_VALUE_WKND(int, Tag2)
\r
92 , aux::cast2nd_impl< AUX778076_OP_IMPL_NAME<Tag1,Tag1>,Tag1,Tag2 >
\r
93 , aux::cast1st_impl< AUX778076_OP_IMPL_NAME<Tag2,Tag2>,Tag1,Tag2 >
\r
98 /// for Digital Mars C++/compilers with no CTPS/TTP support
\r
99 template<> struct AUX778076_OP_IMPL_NAME<na,na>
\r
101 template< typename U1, typename U2 > struct apply
\r
103 typedef apply type;
\r
104 BOOST_STATIC_CONSTANT(int, value = 0);
\r
108 #if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
\r
109 template< typename Tag > struct AUX778076_OP_IMPL_NAME<na,Tag>
\r
111 template< typename U1, typename U2 > struct apply
\r
113 typedef apply type;
\r
114 BOOST_STATIC_CONSTANT(int, value = 0);
\r
118 template< typename Tag > struct AUX778076_OP_IMPL_NAME<Tag,na>
\r
120 template< typename U1, typename U2 > struct apply
\r
122 typedef apply type;
\r
123 BOOST_STATIC_CONSTANT(int, value = 0);
\r
127 template<> struct AUX778076_OP_IMPL_NAME<na,integral_c_tag>
\r
129 template< typename U1, typename U2 > struct apply
\r
131 typedef apply type;
\r
132 BOOST_STATIC_CONSTANT(int, value = 0);
\r
136 template<> struct AUX778076_OP_IMPL_NAME<integral_c_tag,na>
\r
138 template< typename U1, typename U2 > struct apply
\r
140 typedef apply type;
\r
141 BOOST_STATIC_CONSTANT(int, value = 0);
\r
147 #if defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) \
\r
148 && BOOST_WORKAROUND(BOOST_MSVC, >= 1300)
\r
149 template< typename T > struct AUX778076_OP_TAG_NAME
\r
154 template< typename T > struct AUX778076_OP_TAG_NAME
\r
156 typedef typename T::tag type;
\r
161 #if AUX778076_OP_ARITY != 2
\r
163 # if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
\r
165 # define AUX778076_OP_RIGHT_OPERAND(unused, i, N) , BOOST_PP_CAT(N, BOOST_MPL_PP_ADD(i, 2))>
\r
166 # define AUX778076_OP_N_CALLS(i, N) \
\r
167 BOOST_MPL_PP_REPEAT( BOOST_PP_DEC(i), BOOST_MPL_PP_REPEAT_IDENTITY_FUNC, AUX778076_OP_NAME< ) \
\r
168 N1 BOOST_MPL_PP_REPEAT( BOOST_MPL_PP_SUB(i, 1), AUX778076_OP_RIGHT_OPERAND, N ) \
\r
172 typename BOOST_MPL_AUX_NA_PARAM(N1)
\r
173 , typename BOOST_MPL_AUX_NA_PARAM(N2)
\r
174 BOOST_MPL_PP_DEF_PARAMS_TAIL(2, typename N, na)
\r
176 struct AUX778076_OP_NAME
\r
177 : AUX778076_OP_N_CALLS(AUX778076_OP_ARITY, N)
\r
179 BOOST_MPL_AUX_LAMBDA_SUPPORT(
\r
181 , AUX778076_OP_NAME
\r
182 , ( BOOST_MPL_PP_PARAMS(AUX778076_OP_ARITY, N) )
\r
186 #define BOOST_PP_ITERATION_PARAMS_1 \
\r
187 (3,( BOOST_PP_DEC(AUX778076_OP_ARITY), 2, <boost/mpl/aux_/numeric_op.hpp> ))
\r
188 #include BOOST_PP_ITERATE()
\r
190 # undef AUX778076_OP_N_CALLS
\r
191 # undef AUX778076_OP_RIGHT_OPERAND
\r
193 # else // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
\r
195 /// forward declaration
\r
197 typename BOOST_MPL_AUX_NA_PARAM(N1)
\r
198 , typename BOOST_MPL_AUX_NA_PARAM(N2)
\r
200 struct BOOST_PP_CAT(AUX778076_OP_NAME,2);
\r
203 typename BOOST_MPL_AUX_NA_PARAM(N1)
\r
204 , typename BOOST_MPL_AUX_NA_PARAM(N2)
\r
205 BOOST_MPL_PP_DEF_PARAMS_TAIL(2, typename N, na)
\r
207 struct AUX778076_OP_NAME
\r
208 #if BOOST_WORKAROUND(BOOST_MSVC, == 1300)
\r
209 : aux::msvc_eti_base< typename if_<
\r
214 , BOOST_PP_CAT(AUX778076_OP_NAME,2)<N1,N2>
\r
215 , AUX778076_OP_NAME<
\r
216 BOOST_PP_CAT(AUX778076_OP_NAME,2)<N1,N2>
\r
217 , BOOST_MPL_PP_EXT_PARAMS(3, BOOST_PP_INC(AUX778076_OP_ARITY), N)
\r
220 #if BOOST_WORKAROUND(BOOST_MSVC, == 1300)
\r
224 BOOST_MPL_AUX_LAMBDA_SUPPORT(
\r
226 , AUX778076_OP_NAME
\r
227 , ( BOOST_MPL_PP_PARAMS(AUX778076_OP_ARITY, N) )
\r
235 struct BOOST_PP_CAT(AUX778076_OP_NAME,2)
\r
239 #else // AUX778076_OP_ARITY == 2
\r
242 typename BOOST_MPL_AUX_NA_PARAM(N1)
\r
243 , typename BOOST_MPL_AUX_NA_PARAM(N2)
\r
245 struct AUX778076_OP_NAME
\r
249 #if !defined(BOOST_MPL_CFG_MSVC_ETI_BUG)
\r
250 : AUX778076_OP_IMPL_NAME<
\r
251 typename AUX778076_OP_TAG_NAME<N1>::type
\r
252 , typename AUX778076_OP_TAG_NAME<N2>::type
\r
253 >::template apply<N1,N2>::type
\r
255 : aux::msvc_eti_base< typename apply_wrap2<
\r
256 AUX778076_OP_IMPL_NAME<
\r
257 typename AUX778076_OP_TAG_NAME<N1>::type
\r
258 , typename AUX778076_OP_TAG_NAME<N2>::type
\r
265 #if AUX778076_OP_ARITY != 2
\r
267 # if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
\r
268 BOOST_MPL_AUX_LAMBDA_SUPPORT_SPEC(
\r
270 , AUX778076_OP_NAME
\r
271 , ( BOOST_MPL_PP_PARTIAL_SPEC_PARAMS(2, N, na) )
\r
274 BOOST_MPL_AUX_LAMBDA_SUPPORT(2, BOOST_PP_CAT(AUX778076_OP_NAME,2), (N1, N2))
\r
278 BOOST_MPL_AUX_LAMBDA_SUPPORT(2, AUX778076_OP_NAME, (N1, N2))
\r
282 BOOST_MPL_AUX_NA_SPEC2(2, AUX778076_OP_ARITY, AUX778076_OP_NAME)
\r
286 #endif // BOOST_MPL_CFG_NO_PREPROCESSED_HEADERS
\r
288 ///// iteration, depth == 1
\r
290 // For gcc 4.4 compatability, we must include the
\r
291 // BOOST_PP_ITERATION_DEPTH test inside an #else clause.
\r
292 #else // BOOST_PP_IS_ITERATING
\r
293 #if BOOST_PP_ITERATION_DEPTH() == 1
\r
295 # define i_ BOOST_PP_FRAME_ITERATION(1)
\r
298 BOOST_MPL_PP_PARAMS(i_, typename N)
\r
300 struct AUX778076_OP_NAME<BOOST_MPL_PP_PARTIAL_SPEC_PARAMS(i_, N, na)>
\r
302 : AUX778076_OP_N_CALLS(i_, N)
\r
304 BOOST_MPL_AUX_LAMBDA_SUPPORT_SPEC(
\r
306 , AUX778076_OP_NAME
\r
307 , ( BOOST_MPL_PP_PARTIAL_SPEC_PARAMS(i_, N, na) )
\r
314 #endif // BOOST_PP_ITERATION_DEPTH()
\r
315 #endif // BOOST_PP_IS_ITERATING
\r