source: NonGTP/Boost/boost/mpl/apply_wrap.hpp @ 857

Revision 857, 5.4 KB checked in by igarcia, 19 years ago (diff)
RevLine 
[857]1
2#if !defined(BOOST_PP_IS_ITERATING)
3
4///// header body
5
6#ifndef BOOST_MPL_APPLY_WRAP_HPP_INCLUDED
7#define BOOST_MPL_APPLY_WRAP_HPP_INCLUDED
8
9// Copyright Aleksey Gurtovoy 2000-2004
10//
11// Distributed under the Boost Software License, Version 1.0.
12// (See accompanying file LICENSE_1_0.txt or copy at
13// http://www.boost.org/LICENSE_1_0.txt)
14//
15// See http://www.boost.org/libs/mpl for documentation.
16
17// $Source: /cvsroot/boost/boost/boost/mpl/apply_wrap.hpp,v $
18// $Date: 2004/09/03 15:56:55 $
19// $Revision: 1.3 $
20
21#if !defined(BOOST_MPL_PREPROCESSING_MODE)
22#   include <boost/mpl/aux_/arity.hpp>
23#   include <boost/mpl/aux_/has_apply.hpp>
24#   include <boost/mpl/aux_/na.hpp>
25#   include <boost/mpl/aux_/msvc_never_true.hpp>
26#endif
27
28#include <boost/mpl/aux_/config/use_preprocessed.hpp>
29
30#if !defined(BOOST_MPL_CFG_NO_PREPROCESSED_HEADERS) \
31    && !defined(BOOST_MPL_PREPROCESSING_MODE)
32
33#   define BOOST_MPL_PREPROCESSED_HEADER apply_wrap.hpp
34#   include <boost/mpl/aux_/include_preprocessed.hpp>
35
36#else
37
38#   include <boost/mpl/limits/arity.hpp>
39#   include <boost/mpl/aux_/preprocessor/params.hpp>
40#   include <boost/mpl/aux_/preprocessor/enum.hpp>
41#   include <boost/mpl/aux_/preprocessor/add.hpp>
42#   include <boost/mpl/aux_/config/dtp.hpp>
43#   include <boost/mpl/aux_/config/eti.hpp>
44#   include <boost/mpl/aux_/config/ctps.hpp>
45#   include <boost/mpl/aux_/config/msvc.hpp>
46#   include <boost/mpl/aux_/config/workaround.hpp>
47
48#   include <boost/preprocessor/comma_if.hpp>
49#   include <boost/preprocessor/logical/and.hpp>
50#   include <boost/preprocessor/inc.hpp>
51#   include <boost/preprocessor/iterate.hpp>
52
53
54namespace boost { namespace mpl {
55
56// local macros, #undef-ined at the end of the header
57#   define AUX778076_APPLY_WRAP_PARAMS(n, param) \
58    BOOST_MPL_PP_PARAMS(n, param) \
59    /**/
60
61#   define AUX778076_APPLY_WRAP_SPEC_PARAMS(n, param) \
62    BOOST_MPL_PP_ENUM(BOOST_PP_INC(n), param) \
63    /**/
64
65
66#define BOOST_PP_ITERATION_PARAMS_1 \
67    (3,(0, BOOST_MPL_LIMIT_METAFUNCTION_ARITY, <boost/mpl/apply_wrap.hpp>))
68#include BOOST_PP_ITERATE()
69
70
71#   undef AUX778076_APPLY_WRAP_SPEC_PARAMS
72#   undef AUX778076_APPLY_WRAP_PARAMS
73
74}}
75
76#endif // BOOST_MPL_CFG_NO_PREPROCESSED_HEADERS
77#endif // BOOST_MPL_APPLY_WRAP_HPP_INCLUDED
78
79///// iteration, depth == 1
80
81#elif BOOST_PP_ITERATION_DEPTH() == 1
82
83#   define i_ BOOST_PP_FRAME_ITERATION(1)
84
85#   if BOOST_WORKAROUND(BOOST_MSVC, < 1300)
86// MSVC version
87
88#define AUX778076_MSVC_DTW_NAME BOOST_PP_CAT(msvc_apply,i_)
89#define AUX778076_MSVC_DTW_ORIGINAL_NAME apply
90#define AUX778076_MSVC_DTW_ARITY i_
91#include <boost/mpl/aux_/msvc_dtw.hpp>
92
93template<
94      typename F BOOST_PP_COMMA_IF(i_) AUX778076_APPLY_WRAP_PARAMS(i_, typename T)
95    >
96struct BOOST_PP_CAT(apply_wrap,i_)
97{
98    // Metafunction forwarding confuses vc6
99    typedef typename BOOST_PP_CAT(msvc_apply,i_)<F>::template result_<
100          AUX778076_APPLY_WRAP_PARAMS(i_, T)
101        >::type type;
102};
103
104#   elif defined(BOOST_MPL_CFG_BROKEN_DEFAULT_PARAMETERS_IN_NESTED_TEMPLATES)
105// MWCW/Borland version
106
107template<
108      int N, typename F BOOST_PP_COMMA_IF(i_) AUX778076_APPLY_WRAP_PARAMS(i_, typename T)
109    >
110struct BOOST_PP_CAT(apply_wrap_impl,i_);
111
112#define BOOST_PP_ITERATION_PARAMS_2 \
113    (3,(0, BOOST_MPL_LIMIT_METAFUNCTION_ARITY - i_, <boost/mpl/apply_wrap.hpp>))
114#include BOOST_PP_ITERATE()
115
116template<
117      typename F BOOST_PP_COMMA_IF(i_) AUX778076_APPLY_WRAP_PARAMS(i_, typename T)
118    >
119struct BOOST_PP_CAT(apply_wrap,i_)
120    : BOOST_PP_CAT(apply_wrap_impl,i_)<
121          ::boost::mpl::aux::arity<F,i_>::value
122        , F
123        BOOST_PP_COMMA_IF(i_) AUX778076_APPLY_WRAP_PARAMS(i_, T)
124        >::type
125{
126};
127
128#   else
129// ISO98 C++, with minor concession to vc7
130
131template<
132      typename F BOOST_PP_COMMA_IF(i_) AUX778076_APPLY_WRAP_PARAMS(i_, typename T)
133#if i_ == 0
134    , typename has_apply_ = typename aux::has_apply<F>::type
135#endif
136    >
137struct BOOST_PP_CAT(apply_wrap,i_)
138// metafunction forwarding confuses MSVC 7.0
139#if !BOOST_WORKAROUND(BOOST_MSVC, == 1300)
140    : F::template apply< AUX778076_APPLY_WRAP_PARAMS(i_, T) >
141{
142#else
143{   
144    typedef typename F::template apply<
145         AUX778076_APPLY_WRAP_PARAMS(i_, T)
146        >::type type;
147#endif
148};
149
150#if i_ == 0 && !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
151template< typename F >
152struct BOOST_PP_CAT(apply_wrap,i_)<F,true_>
153    : F::apply
154{
155};
156#endif
157
158#   endif // workarounds
159
160#if defined(BOOST_MPL_CFG_MSVC_ETI_BUG)
161/// workaround for ETI bug
162template<>
163struct BOOST_PP_CAT(apply_wrap,i_)<AUX778076_APPLY_WRAP_SPEC_PARAMS(i_, int)>
164{
165    typedef int type;
166};
167#endif
168
169#   undef i_
170
171///// iteration, depth == 2
172
173#elif BOOST_PP_ITERATION_DEPTH() == 2
174
175#   define j_ BOOST_PP_FRAME_ITERATION(2)
176
177template<
178      typename F BOOST_PP_COMMA_IF(i_) AUX778076_APPLY_WRAP_PARAMS(i_, typename T)
179    >
180struct BOOST_PP_CAT(apply_wrap_impl,i_)<
181          BOOST_MPL_PP_ADD(i_, j_)
182        , F
183        BOOST_PP_COMMA_IF(i_) AUX778076_APPLY_WRAP_PARAMS(i_, T)
184        >
185{
186    typedef typename F::template apply<
187          AUX778076_APPLY_WRAP_PARAMS(i_, T)
188#if i_ == 0 && j_ == 0
189/// since the defaults are "lost", we have to pass *something* even for nullary
190/// metafunction classes
191        na
192#else
193        BOOST_PP_COMMA_IF(BOOST_PP_AND(i_, j_)) BOOST_MPL_PP_ENUM(j_, na)
194#endif
195        > type;
196};
197
198#   undef j_
199
200#endif // BOOST_PP_IS_ITERATING
Note: See TracBrowser for help on using the repository browser.