source: NonGTP/Boost/boost/mpl/aux_/numeric_op.hpp @ 857

Revision 857, 8.5 KB checked in by igarcia, 19 years ago (diff)
Line 
1
2#if !defined(BOOST_PP_IS_ITERATING)
3
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// $Source: /cvsroot/boost/boost/boost/mpl/aux_/numeric_op.hpp,v $
17// $Date: 2004/12/20 19:17:06 $
18// $Revision: 1.9 $
19
20#if !defined(BOOST_MPL_PREPROCESSING_MODE)
21#   include <boost/mpl/numeric_cast.hpp>
22#   include <boost/mpl/apply_wrap.hpp>
23#   include <boost/mpl/if.hpp>
24#   include <boost/mpl/tag.hpp>
25#   include <boost/mpl/aux_/numeric_cast_utils.hpp>
26#   include <boost/mpl/aux_/na.hpp>
27#   include <boost/mpl/aux_/na_spec.hpp>
28#   include <boost/mpl/aux_/lambda_support.hpp>
29#   include <boost/mpl/aux_/msvc_eti_base.hpp>
30#   include <boost/mpl/aux_/value_wknd.hpp>
31#   include <boost/mpl/aux_/config/eti.hpp>
32#   include <boost/mpl/aux_/nttp_decl.hpp>
33#endif
34
35#include <boost/mpl/aux_/config/static_constant.hpp>
36
37#if defined(BOOST_MPL_CFG_NO_PREPROCESSED_HEADERS) \
38    || defined(BOOST_MPL_PREPROCESSING_MODE)
39
40#   include <boost/mpl/limits/arity.hpp>
41#   include <boost/mpl/aux_/preprocessor/partial_spec_params.hpp>
42#   include <boost/mpl/aux_/preprocessor/def_params_tail.hpp>
43#   include <boost/mpl/aux_/preprocessor/repeat.hpp>
44#   include <boost/mpl/aux_/preprocessor/ext_params.hpp>
45#   include <boost/mpl/aux_/preprocessor/params.hpp>
46#   include <boost/mpl/aux_/preprocessor/enum.hpp>
47#   include <boost/mpl/aux_/preprocessor/add.hpp>
48#   include <boost/mpl/aux_/preprocessor/sub.hpp>
49#   include <boost/mpl/aux_/config/ctps.hpp>
50#   include <boost/mpl/aux_/config/eti.hpp>
51#   include <boost/mpl/aux_/config/msvc.hpp>
52#   include <boost/mpl/aux_/config/workaround.hpp>
53
54#   include <boost/preprocessor/dec.hpp>
55#   include <boost/preprocessor/inc.hpp>
56#   include <boost/preprocessor/iterate.hpp>
57#   include <boost/preprocessor/cat.hpp>
58
59
60#if !defined(AUX778076_OP_ARITY)
61#   define AUX778076_OP_ARITY BOOST_MPL_LIMIT_METAFUNCTION_ARITY
62#endif
63
64#if !defined(AUX778076_OP_IMPL_NAME)
65#   define AUX778076_OP_IMPL_NAME BOOST_PP_CAT(AUX778076_OP_PREFIX,_impl)
66#endif
67
68#if !defined(AUX778076_OP_TAG_NAME)
69#   define AUX778076_OP_TAG_NAME BOOST_PP_CAT(AUX778076_OP_PREFIX,_tag)
70#endif
71
72namespace boost { namespace mpl {
73
74template<
75      typename Tag1
76    , typename Tag2
77#if BOOST_WORKAROUND(BOOST_MSVC, <= 1300)
78    , BOOST_MPL_AUX_NTTP_DECL(int, tag1_) = BOOST_MPL_AUX_MSVC_VALUE_WKND(Tag1)::value
79    , BOOST_MPL_AUX_NTTP_DECL(int, tag2_) = BOOST_MPL_AUX_MSVC_VALUE_WKND(Tag2)::value
80    >
81struct AUX778076_OP_IMPL_NAME
82    : if_c<
83          ( tag1_ > tag2_ )
84#else
85    >
86struct AUX778076_OP_IMPL_NAME
87    : if_c<
88          ( BOOST_MPL_AUX_NESTED_VALUE_WKND(int, Tag1)
89              > BOOST_MPL_AUX_NESTED_VALUE_WKND(int, Tag2)
90            )
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;
104        BOOST_STATIC_CONSTANT(int, value = 0);
105    };
106};
107
108#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
109template< typename Tag > struct AUX778076_OP_IMPL_NAME<na,Tag>
110{
111    template< typename U1, typename U2 > struct apply
112    {
113        typedef apply type;
114        BOOST_STATIC_CONSTANT(int, value = 0);
115    };
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;
123        BOOST_STATIC_CONSTANT(int, value = 0);
124    };
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;
132        BOOST_STATIC_CONSTANT(int, value = 0);
133    };
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;
141        BOOST_STATIC_CONSTANT(int, value = 0);
142    };
143};
144#endif
145
146
147#if defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) \
148    && BOOST_WORKAROUND(BOOST_MSVC, != 1200)
149template< 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
163#   if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
164
165#   define AUX778076_OP_RIGHT_OPERAND(unused, i, N) , BOOST_PP_CAT(N, BOOST_MPL_PP_ADD(i, 2))>
166#   define AUX778076_OP_N_CALLS(i, N) \
167    BOOST_MPL_PP_REPEAT( BOOST_PP_DEC(i), BOOST_MPL_PP_REPEAT_IDENTITY_FUNC, AUX778076_OP_NAME< ) \
168    N1 BOOST_MPL_PP_REPEAT( BOOST_MPL_PP_SUB(i, 1), AUX778076_OP_RIGHT_OPERAND, N ) \
169/**/
170
171template<
172      typename BOOST_MPL_AUX_NA_PARAM(N1)
173    , typename BOOST_MPL_AUX_NA_PARAM(N2)
174    BOOST_MPL_PP_DEF_PARAMS_TAIL(2, typename N, na)
175    >
176struct AUX778076_OP_NAME
177    : AUX778076_OP_N_CALLS(AUX778076_OP_ARITY, N)
178{
179    BOOST_MPL_AUX_LAMBDA_SUPPORT(
180          AUX778076_OP_ARITY
181        , AUX778076_OP_NAME
182        , ( BOOST_MPL_PP_PARAMS(AUX778076_OP_ARITY, N) )
183        )
184};
185
186#define BOOST_PP_ITERATION_PARAMS_1 \
187    (3,( BOOST_PP_DEC(AUX778076_OP_ARITY), 2, <boost/mpl/aux_/numeric_op.hpp> ))
188#include BOOST_PP_ITERATE()
189
190#   undef AUX778076_OP_N_CALLS
191#   undef AUX778076_OP_RIGHT_OPERAND
192
193#   else // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
194
195/// forward declaration
196template<
197      typename BOOST_MPL_AUX_NA_PARAM(N1)
198    , typename BOOST_MPL_AUX_NA_PARAM(N2)
199    >
200struct BOOST_PP_CAT(AUX778076_OP_NAME,2);
201
202template<
203      typename BOOST_MPL_AUX_NA_PARAM(N1)
204    , typename BOOST_MPL_AUX_NA_PARAM(N2)
205    BOOST_MPL_PP_DEF_PARAMS_TAIL(2, typename N, na)
206    >
207struct AUX778076_OP_NAME
208#if BOOST_WORKAROUND(BOOST_MSVC, == 1300)
209    : aux::msvc_eti_base< typename if_<
210#else
211    : if_<
212#endif
213          is_na<N3>
214        , BOOST_PP_CAT(AUX778076_OP_NAME,2)<N1,N2>
215        , AUX778076_OP_NAME<
216              BOOST_PP_CAT(AUX778076_OP_NAME,2)<N1,N2>
217            , BOOST_MPL_PP_EXT_PARAMS(3, BOOST_PP_INC(AUX778076_OP_ARITY), N)
218            >
219        >::type
220#if BOOST_WORKAROUND(BOOST_MSVC, == 1300)
221    >
222#endif
223{
224    BOOST_MPL_AUX_LAMBDA_SUPPORT(
225          AUX778076_OP_ARITY
226        , AUX778076_OP_NAME
227        , ( BOOST_MPL_PP_PARAMS(AUX778076_OP_ARITY, N) )
228        )
229};
230
231template<
232      typename N1
233    , typename N2
234    >
235struct BOOST_PP_CAT(AUX778076_OP_NAME,2)
236
237#endif
238
239#else // AUX778076_OP_ARITY == 2
240
241template<
242      typename BOOST_MPL_AUX_NA_PARAM(N1)
243    , typename BOOST_MPL_AUX_NA_PARAM(N2)
244    >
245struct AUX778076_OP_NAME
246
247#endif
248
249#if !defined(BOOST_MPL_CFG_MSVC_ETI_BUG)
250    : 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
267#   if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
268    BOOST_MPL_AUX_LAMBDA_SUPPORT_SPEC(
269          AUX778076_OP_ARITY
270        , AUX778076_OP_NAME
271        , ( BOOST_MPL_PP_PARTIAL_SPEC_PARAMS(2, N, na) )
272        )
273#   else
274    BOOST_MPL_AUX_LAMBDA_SUPPORT(2, BOOST_PP_CAT(AUX778076_OP_NAME,2), (N1, N2))
275#   endif
276
277#else
278    BOOST_MPL_AUX_LAMBDA_SUPPORT(2, AUX778076_OP_NAME, (N1, N2))
279#endif
280};
281
282BOOST_MPL_AUX_NA_SPEC2(2, AUX778076_OP_ARITY, AUX778076_OP_NAME)
283
284}}
285
286#endif // BOOST_MPL_CFG_NO_PREPROCESSED_HEADERS
287
288///// iteration, depth == 1
289
290#elif BOOST_PP_ITERATION_DEPTH() == 1
291
292#   define i_ BOOST_PP_FRAME_ITERATION(1)
293
294template<
295      BOOST_MPL_PP_PARAMS(i_, typename N)
296    >
297struct AUX778076_OP_NAME<BOOST_MPL_PP_PARTIAL_SPEC_PARAMS(i_, N, na)>
298#if i_ != 2
299    : AUX778076_OP_N_CALLS(i_, N)
300{
301    BOOST_MPL_AUX_LAMBDA_SUPPORT_SPEC(
302          AUX778076_OP_ARITY
303        , AUX778076_OP_NAME
304        , ( BOOST_MPL_PP_PARTIAL_SPEC_PARAMS(i_, N, na) )
305        )
306};
307#endif
308
309#   undef i_
310
311#endif // BOOST_PP_IS_ITERATING
Note: See TracBrowser for help on using the repository browser.