Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/boost_1_33_1/boost/mpl/apply.hpp @ 12

Last change on this file since 12 was 12, checked in by landauf, 17 years ago

added boost

File size: 5.9 KB
Line 
1
2#if !defined(BOOST_PP_IS_ITERATING)
3
4///// header body
5
6#ifndef BOOST_MPL_APPLY_HPP_INCLUDED
7#define BOOST_MPL_APPLY_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.hpp,v $
18// $Date: 2004/09/02 15:40:41 $
19// $Revision: 1.17 $
20
21#if !defined(BOOST_MPL_PREPROCESSING_MODE)
22#   include <boost/mpl/apply_fwd.hpp>
23#   include <boost/mpl/apply_wrap.hpp>
24#   include <boost/mpl/placeholders.hpp>
25#   include <boost/mpl/lambda.hpp>
26#   include <boost/mpl/aux_/na.hpp>
27#   include <boost/mpl/aux_/lambda_support.hpp>
28#endif
29
30#include <boost/mpl/aux_/config/use_preprocessed.hpp>
31
32#if !defined(BOOST_MPL_CFG_NO_PREPROCESSED_HEADERS) \
33    && !defined(BOOST_MPL_PREPROCESSING_MODE)
34
35#   define BOOST_MPL_PREPROCESSED_HEADER apply.hpp
36#   include <boost/mpl/aux_/include_preprocessed.hpp>
37
38#else
39
40#   include <boost/mpl/limits/arity.hpp>
41#   include <boost/mpl/aux_/preprocessor/params.hpp>
42#   include <boost/mpl/aux_/preprocessor/default_params.hpp>
43#   include <boost/mpl/aux_/preprocessor/partial_spec_params.hpp>
44#   include <boost/mpl/aux_/preprocessor/enum.hpp>
45#   include <boost/mpl/aux_/config/lambda.hpp>
46#   include <boost/mpl/aux_/config/dtp.hpp>
47#   include <boost/mpl/aux_/nttp_decl.hpp>
48#   include <boost/mpl/aux_/config/eti.hpp>
49#   include <boost/mpl/aux_/config/msvc.hpp>
50#   include <boost/mpl/aux_/config/workaround.hpp>
51
52#   include <boost/preprocessor/comma_if.hpp>
53#   include <boost/preprocessor/inc.hpp>
54#   include <boost/preprocessor/iterate.hpp>
55#   include <boost/preprocessor/cat.hpp>
56
57namespace boost { namespace mpl {
58
59// local macros, #undef-ined at the end of the header
60#   define AUX778076_APPLY_PARAMS(param) \
61    BOOST_MPL_PP_PARAMS( \
62          BOOST_MPL_LIMIT_METAFUNCTION_ARITY \
63        , param \
64        ) \
65    /**/
66
67#   define AUX778076_APPLY_DEF_PARAMS(param, value) \
68    BOOST_MPL_PP_DEFAULT_PARAMS( \
69          BOOST_MPL_LIMIT_METAFUNCTION_ARITY \
70        , param \
71        , value \
72        ) \
73    /**/
74
75#   define AUX778076_APPLY_N_PARAMS(n, param) \
76    BOOST_MPL_PP_PARAMS(n, param) \
77    /**/
78
79#   define AUX778076_APPLY_N_COMMA_PARAMS(n, param) \
80    BOOST_PP_COMMA_IF(n) \
81    BOOST_MPL_PP_PARAMS(n, param) \
82    /**/
83
84#   define AUX778076_APPLY_N_PARTIAL_SPEC_PARAMS(n, param, def) \
85    BOOST_PP_COMMA_IF(n) \
86    BOOST_MPL_PP_PARTIAL_SPEC_PARAMS(n, param, def) \
87    /**/
88   
89#   define AUX778076_APPLY_N_SPEC_PARAMS(n, param) \
90    BOOST_MPL_PP_ENUM(BOOST_PP_INC(n), param) \
91    /**/
92
93
94#define BOOST_PP_ITERATION_PARAMS_1 \
95    (3,(0, BOOST_MPL_LIMIT_METAFUNCTION_ARITY, <boost/mpl/apply.hpp>))
96#include BOOST_PP_ITERATE()
97
98#   if !defined(BOOST_MPL_CFG_NO_APPLY_TEMPLATE)
99// real C++ version is already taken care of
100#   if defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
101
102namespace aux {
103// apply_count_args
104#define AUX778076_COUNT_ARGS_PREFIX apply
105#define AUX778076_COUNT_ARGS_DEFAULT na
106#define AUX778076_COUNT_ARGS_ARITY BOOST_MPL_LIMIT_METAFUNCTION_ARITY
107#include <boost/mpl/aux_/count_args.hpp>
108}
109
110
111template<
112      typename F, AUX778076_APPLY_DEF_PARAMS(typename T, na)
113    >
114struct apply
115    : aux::apply_chooser< 
116          aux::apply_count_args< AUX778076_APPLY_PARAMS(T) >::value
117        >::template result_< F, AUX778076_APPLY_PARAMS(T) >::type
118{
119};
120
121#   endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
122#   endif // BOOST_MPL_CFG_NO_APPLY_TEMPLATE
123
124#   undef AUX778076_APPLY_N_SPEC_PARAMS
125#   undef AUX778076_APPLY_N_PARTIAL_SPEC_PARAMS
126#   undef AUX778076_APPLY_N_COMMA_PARAMS
127#   undef AUX778076_APPLY_N_PARAMS
128#   undef AUX778076_APPLY_DEF_PARAMS
129#   undef AUX778076_APPLY_PARAMS
130
131}}
132
133#endif // BOOST_MPL_CFG_NO_PREPROCESSED_HEADERS
134#endif // BOOST_MPL_APPLY_HPP_INCLUDED
135
136///// iteration, depth == 1
137
138#elif BOOST_PP_ITERATION_DEPTH() == 1
139
140#   define i_ BOOST_PP_FRAME_ITERATION(1)
141
142template<
143      typename F AUX778076_APPLY_N_COMMA_PARAMS(i_, typename T)
144    >
145struct BOOST_PP_CAT(apply,i_)
146#if !BOOST_WORKAROUND(BOOST_MSVC, < 1300)
147    : BOOST_PP_CAT(apply_wrap,i_)< 
148          typename lambda<F>::type
149        AUX778076_APPLY_N_COMMA_PARAMS(i_, T)
150        >
151{
152#else
153{
154    typedef typename BOOST_PP_CAT(apply_wrap,i_)< 
155          typename lambda<F>::type
156        AUX778076_APPLY_N_COMMA_PARAMS(i_, T)
157        >::type type;
158#endif
159    BOOST_MPL_AUX_LAMBDA_SUPPORT(
160          BOOST_PP_INC(i_)
161        , BOOST_PP_CAT(apply,i_)
162        , (F AUX778076_APPLY_N_COMMA_PARAMS(i_,T))
163        )
164};
165
166
167#if defined(BOOST_MPL_CFG_MSVC_ETI_BUG)
168/// workaround for ETI bug
169template<>
170struct BOOST_PP_CAT(apply,i_)<AUX778076_APPLY_N_SPEC_PARAMS(i_, int)>
171{
172    typedef int type;
173};
174#endif
175
176#   if !defined(BOOST_MPL_CFG_NO_APPLY_TEMPLATE)
177#   if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
178
179#if i_ == BOOST_MPL_LIMIT_METAFUNCTION_ARITY
180/// primary template (not a specialization!)
181template<
182      typename F AUX778076_APPLY_N_COMMA_PARAMS(i_, typename T)
183    >
184struct apply
185    : BOOST_PP_CAT(apply,i_)< F AUX778076_APPLY_N_COMMA_PARAMS(i_, T) >
186{
187};
188#else
189template<
190      typename F AUX778076_APPLY_N_COMMA_PARAMS(i_, typename T)
191    >
192struct apply< F AUX778076_APPLY_N_PARTIAL_SPEC_PARAMS(i_, T, na) >
193    : BOOST_PP_CAT(apply,i_)< F AUX778076_APPLY_N_COMMA_PARAMS(i_, T) >
194{
195};
196#endif
197
198#   else // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
199
200#if !defined(BOOST_MPL_CFG_NO_APPLY_TEMPLATE)
201namespace aux {
202
203template<>
204struct apply_chooser<i_>
205{
206    template<
207          typename F, AUX778076_APPLY_PARAMS(typename T)
208        >
209    struct result_
210    {
211        typedef BOOST_PP_CAT(apply,i_)<
212              F AUX778076_APPLY_N_COMMA_PARAMS(i_, T)
213            > type;
214    };
215};
216
217} // namespace aux
218#endif
219
220#   endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
221#   endif // BOOST_MPL_CFG_NO_APPLY_TEMPLATE
222
223#   undef i_
224
225#endif // BOOST_PP_IS_ITERATING
Note: See TracBrowser for help on using the repository browser.