blob: 0fd6612a1956deda3d1e71e976406a98f11cb08d [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
Jeff Thompson3d613fd2013-10-15 15:39:04 -07006#ifndef NDNBOOST_MPL_APPLY_HPP_INCLUDED
7#define NDNBOOST_MPL_APPLY_HPP_INCLUDED
Jeff Thompsona28eed82013-08-22 16:21:10 -07008
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// $Id: apply.hpp 49267 2008-10-11 06:19:02Z agurtovoy $
18// $Date: 2008-10-10 23:19:02 -0700 (Fri, 10 Oct 2008) $
19// $Revision: 49267 $
20
Jeff Thompson3d613fd2013-10-15 15:39:04 -070021#if !defined(NDNBOOST_MPL_PREPROCESSING_MODE)
Jeff Thompsona28eed82013-08-22 16:21:10 -070022# include <ndnboost/mpl/apply_fwd.hpp>
23# include <ndnboost/mpl/apply_wrap.hpp>
24# include <ndnboost/mpl/placeholders.hpp>
25# include <ndnboost/mpl/lambda.hpp>
26# include <ndnboost/mpl/aux_/na.hpp>
27# include <ndnboost/mpl/aux_/lambda_support.hpp>
28#endif
29
30#include <ndnboost/mpl/aux_/config/use_preprocessed.hpp>
31
Jeff Thompson3d613fd2013-10-15 15:39:04 -070032#if !defined(NDNBOOST_MPL_CFG_NO_PREPROCESSED_HEADERS) \
33 && !defined(NDNBOOST_MPL_PREPROCESSING_MODE)
Jeff Thompsona28eed82013-08-22 16:21:10 -070034
Jeff Thompson3d613fd2013-10-15 15:39:04 -070035# define NDNBOOST_MPL_PREPROCESSED_HEADER apply.hpp
Jeff Thompsona28eed82013-08-22 16:21:10 -070036# include <ndnboost/mpl/aux_/include_preprocessed.hpp>
37
38#else
39
40# include <ndnboost/mpl/limits/arity.hpp>
41# include <ndnboost/mpl/aux_/preprocessor/params.hpp>
42# include <ndnboost/mpl/aux_/preprocessor/default_params.hpp>
43# include <ndnboost/mpl/aux_/preprocessor/partial_spec_params.hpp>
44# include <ndnboost/mpl/aux_/preprocessor/enum.hpp>
45# include <ndnboost/mpl/aux_/config/lambda.hpp>
46# include <ndnboost/mpl/aux_/config/dtp.hpp>
47# include <ndnboost/mpl/aux_/nttp_decl.hpp>
48# include <ndnboost/mpl/aux_/config/eti.hpp>
49# include <ndnboost/mpl/aux_/config/msvc.hpp>
50# include <ndnboost/mpl/aux_/config/workaround.hpp>
51
52# include <ndnboost/preprocessor/comma_if.hpp>
53# include <ndnboost/preprocessor/inc.hpp>
54# include <ndnboost/preprocessor/iterate.hpp>
55# include <ndnboost/preprocessor/cat.hpp>
56
57namespace ndnboost { namespace mpl {
58
59// local macros, #undef-ined at the end of the header
60# define AUX778076_APPLY_PARAMS(param) \
Jeff Thompson3d613fd2013-10-15 15:39:04 -070061 NDNBOOST_MPL_PP_PARAMS( \
62 NDNBOOST_MPL_LIMIT_METAFUNCTION_ARITY \
Jeff Thompsona28eed82013-08-22 16:21:10 -070063 , param \
64 ) \
65 /**/
66
67# define AUX778076_APPLY_DEF_PARAMS(param, value) \
Jeff Thompson3d613fd2013-10-15 15:39:04 -070068 NDNBOOST_MPL_PP_DEFAULT_PARAMS( \
69 NDNBOOST_MPL_LIMIT_METAFUNCTION_ARITY \
Jeff Thompsona28eed82013-08-22 16:21:10 -070070 , param \
71 , value \
72 ) \
73 /**/
74
75# define AUX778076_APPLY_N_PARAMS(n, param) \
Jeff Thompson3d613fd2013-10-15 15:39:04 -070076 NDNBOOST_MPL_PP_PARAMS(n, param) \
Jeff Thompsona28eed82013-08-22 16:21:10 -070077 /**/
78
79# define AUX778076_APPLY_N_COMMA_PARAMS(n, param) \
Jeff Thompson3d613fd2013-10-15 15:39:04 -070080 NDNBOOST_PP_COMMA_IF(n) \
81 NDNBOOST_MPL_PP_PARAMS(n, param) \
Jeff Thompsona28eed82013-08-22 16:21:10 -070082 /**/
83
84# define AUX778076_APPLY_N_PARTIAL_SPEC_PARAMS(n, param, def) \
Jeff Thompson3d613fd2013-10-15 15:39:04 -070085 NDNBOOST_PP_COMMA_IF(n) \
86 NDNBOOST_MPL_PP_PARTIAL_SPEC_PARAMS(n, param, def) \
Jeff Thompsona28eed82013-08-22 16:21:10 -070087 /**/
88
89# define AUX778076_APPLY_N_SPEC_PARAMS(n, param) \
Jeff Thompson3d613fd2013-10-15 15:39:04 -070090 NDNBOOST_MPL_PP_ENUM(NDNBOOST_PP_INC(n), param) \
Jeff Thompsona28eed82013-08-22 16:21:10 -070091 /**/
92
93
Jeff Thompson3d613fd2013-10-15 15:39:04 -070094#define NDNBOOST_PP_ITERATION_PARAMS_1 \
95 (3,(0, NDNBOOST_MPL_LIMIT_METAFUNCTION_ARITY, <ndnboost/mpl/apply.hpp>))
96#include NDNBOOST_PP_ITERATE()
Jeff Thompsona28eed82013-08-22 16:21:10 -070097
Jeff Thompson3d613fd2013-10-15 15:39:04 -070098# if !defined(NDNBOOST_MPL_CFG_NO_APPLY_TEMPLATE)
Jeff Thompsona28eed82013-08-22 16:21:10 -070099// real C++ version is already taken care of
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700100# if defined(NDNBOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
Jeff Thompsona28eed82013-08-22 16:21:10 -0700101
102namespace aux {
103// apply_count_args
104#define AUX778076_COUNT_ARGS_PREFIX apply
105#define AUX778076_COUNT_ARGS_DEFAULT na
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700106#define AUX778076_COUNT_ARGS_ARITY NDNBOOST_MPL_LIMIT_METAFUNCTION_ARITY
Jeff Thompsona28eed82013-08-22 16:21:10 -0700107#include <ndnboost/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
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700121# endif // NDNBOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
122# endif // NDNBOOST_MPL_CFG_NO_APPLY_TEMPLATE
Jeff Thompsona28eed82013-08-22 16:21:10 -0700123
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
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700133#endif // NDNBOOST_MPL_CFG_NO_PREPROCESSED_HEADERS
134#endif // NDNBOOST_MPL_APPLY_HPP_INCLUDED
Jeff Thompsona28eed82013-08-22 16:21:10 -0700135
136///// iteration, depth == 1
137
138// For gcc 4.4 compatability, we must include the
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700139// NDNBOOST_PP_ITERATION_DEPTH test inside an #else clause.
140#else // NDNBOOST_PP_IS_ITERATING
141#if NDNBOOST_PP_ITERATION_DEPTH() == 1
Jeff Thompsona28eed82013-08-22 16:21:10 -0700142
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700143# define i_ NDNBOOST_PP_FRAME_ITERATION(1)
Jeff Thompsona28eed82013-08-22 16:21:10 -0700144
145template<
146 typename F AUX778076_APPLY_N_COMMA_PARAMS(i_, typename T)
147 >
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700148struct NDNBOOST_PP_CAT(apply,i_)
149#if !NDNBOOST_WORKAROUND(NDNBOOST_MSVC, < 1300)
150 : NDNBOOST_PP_CAT(apply_wrap,i_)<
Jeff Thompsona28eed82013-08-22 16:21:10 -0700151 typename lambda<F>::type
152 AUX778076_APPLY_N_COMMA_PARAMS(i_, T)
153 >
154{
155#else
156{
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700157 typedef typename NDNBOOST_PP_CAT(apply_wrap,i_)<
Jeff Thompsona28eed82013-08-22 16:21:10 -0700158 typename lambda<F>::type
159 AUX778076_APPLY_N_COMMA_PARAMS(i_, T)
160 >::type type;
161#endif
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700162 NDNBOOST_MPL_AUX_LAMBDA_SUPPORT(
163 NDNBOOST_PP_INC(i_)
164 , NDNBOOST_PP_CAT(apply,i_)
Jeff Thompsona28eed82013-08-22 16:21:10 -0700165 , (F AUX778076_APPLY_N_COMMA_PARAMS(i_,T))
166 )
167};
168
169
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700170#if defined(NDNBOOST_MPL_CFG_MSVC_ETI_BUG)
Jeff Thompsona28eed82013-08-22 16:21:10 -0700171/// workaround for ETI bug
172template<>
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700173struct NDNBOOST_PP_CAT(apply,i_)<AUX778076_APPLY_N_SPEC_PARAMS(i_, int)>
Jeff Thompsona28eed82013-08-22 16:21:10 -0700174{
175 typedef int type;
176};
177#endif
178
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700179# if !defined(NDNBOOST_MPL_CFG_NO_APPLY_TEMPLATE)
180# if !defined(NDNBOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
Jeff Thompsona28eed82013-08-22 16:21:10 -0700181
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700182#if i_ == NDNBOOST_MPL_LIMIT_METAFUNCTION_ARITY
Jeff Thompsona28eed82013-08-22 16:21:10 -0700183/// primary template (not a specialization!)
184template<
185 typename F AUX778076_APPLY_N_COMMA_PARAMS(i_, typename T)
186 >
187struct apply
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700188 : NDNBOOST_PP_CAT(apply,i_)< F AUX778076_APPLY_N_COMMA_PARAMS(i_, T) >
Jeff Thompsona28eed82013-08-22 16:21:10 -0700189{
190};
191#else
192template<
193 typename F AUX778076_APPLY_N_COMMA_PARAMS(i_, typename T)
194 >
195struct apply< F AUX778076_APPLY_N_PARTIAL_SPEC_PARAMS(i_, T, na) >
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700196 : NDNBOOST_PP_CAT(apply,i_)< F AUX778076_APPLY_N_COMMA_PARAMS(i_, T) >
Jeff Thompsona28eed82013-08-22 16:21:10 -0700197{
198};
199#endif
200
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700201# else // NDNBOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
Jeff Thompsona28eed82013-08-22 16:21:10 -0700202
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700203#if !defined(NDNBOOST_MPL_CFG_NO_APPLY_TEMPLATE)
Jeff Thompsona28eed82013-08-22 16:21:10 -0700204namespace aux {
205
206template<>
207struct apply_chooser<i_>
208{
209 template<
210 typename F, AUX778076_APPLY_PARAMS(typename T)
211 >
212 struct result_
213 {
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700214 typedef NDNBOOST_PP_CAT(apply,i_)<
Jeff Thompsona28eed82013-08-22 16:21:10 -0700215 F AUX778076_APPLY_N_COMMA_PARAMS(i_, T)
216 > type;
217 };
218};
219
220} // namespace aux
221#endif
222
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700223# endif // NDNBOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
224# endif // NDNBOOST_MPL_CFG_NO_APPLY_TEMPLATE
Jeff Thompsona28eed82013-08-22 16:21:10 -0700225
226# undef i_
227
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700228#endif // NDNBOOST_PP_ITERATION_DEPTH()
229#endif // NDNBOOST_PP_IS_ITERATING