blob: 5e7c042e84f87620431a132f39c43d36e8e9fd85 [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_WRAP_HPP_INCLUDED
7#define NDNBOOST_MPL_APPLY_WRAP_HPP_INCLUDED
Jeff Thompsona28eed82013-08-22 16:21:10 -07008
9// Copyright Aleksey Gurtovoy 2000-2008
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_wrap.hpp 49272 2008-10-11 06:50:46Z agurtovoy $
18// $Date: 2008-10-10 23:50:46 -0700 (Fri, 10 Oct 2008) $
19// $Revision: 49272 $
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/aux_/arity.hpp>
23# include <ndnboost/mpl/aux_/has_apply.hpp>
24# include <ndnboost/mpl/aux_/na.hpp>
25# include <ndnboost/mpl/aux_/msvc_never_true.hpp>
26#endif
27
28#include <ndnboost/mpl/aux_/config/use_preprocessed.hpp>
29
Jeff Thompson3d613fd2013-10-15 15:39:04 -070030#if !defined(NDNBOOST_MPL_CFG_NO_PREPROCESSED_HEADERS) \
31 && !defined(NDNBOOST_MPL_PREPROCESSING_MODE)
Jeff Thompsona28eed82013-08-22 16:21:10 -070032
Jeff Thompson3d613fd2013-10-15 15:39:04 -070033# define NDNBOOST_MPL_PREPROCESSED_HEADER apply_wrap.hpp
Jeff Thompsona28eed82013-08-22 16:21:10 -070034# include <ndnboost/mpl/aux_/include_preprocessed.hpp>
35
36#else
37
38# include <ndnboost/mpl/limits/arity.hpp>
39# include <ndnboost/mpl/aux_/preprocessor/params.hpp>
40# include <ndnboost/mpl/aux_/preprocessor/enum.hpp>
41# include <ndnboost/mpl/aux_/preprocessor/add.hpp>
42# include <ndnboost/mpl/aux_/config/bcc.hpp>
43# include <ndnboost/mpl/aux_/config/ctps.hpp>
44# include <ndnboost/mpl/aux_/config/dtp.hpp>
45# include <ndnboost/mpl/aux_/config/eti.hpp>
46# include <ndnboost/mpl/aux_/config/msvc.hpp>
47# include <ndnboost/mpl/aux_/config/workaround.hpp>
48
49# include <ndnboost/preprocessor/comma_if.hpp>
50# include <ndnboost/preprocessor/logical/and.hpp>
51# include <ndnboost/preprocessor/inc.hpp>
52# include <ndnboost/preprocessor/iterate.hpp>
53
54
55namespace ndnboost { namespace mpl {
56
57// local macros, #undef-ined at the end of the header
58# define AUX778076_APPLY_WRAP_PARAMS(n, param) \
Jeff Thompson3d613fd2013-10-15 15:39:04 -070059 NDNBOOST_MPL_PP_PARAMS(n, param) \
Jeff Thompsona28eed82013-08-22 16:21:10 -070060 /**/
61
62# define AUX778076_APPLY_WRAP_SPEC_PARAMS(n, param) \
Jeff Thompson3d613fd2013-10-15 15:39:04 -070063 NDNBOOST_MPL_PP_ENUM(NDNBOOST_PP_INC(n), param) \
Jeff Thompsona28eed82013-08-22 16:21:10 -070064 /**/
65
66
Jeff Thompson3d613fd2013-10-15 15:39:04 -070067#define NDNBOOST_PP_ITERATION_PARAMS_1 \
68 (3,(0, NDNBOOST_MPL_LIMIT_METAFUNCTION_ARITY, <ndnboost/mpl/apply_wrap.hpp>))
69#include NDNBOOST_PP_ITERATE()
Jeff Thompsona28eed82013-08-22 16:21:10 -070070
71
72# undef AUX778076_APPLY_WRAP_SPEC_PARAMS
73# undef AUX778076_APPLY_WRAP_PARAMS
74
75}}
76
Jeff Thompson3d613fd2013-10-15 15:39:04 -070077#endif // NDNBOOST_MPL_CFG_NO_PREPROCESSED_HEADERS
78#endif // NDNBOOST_MPL_APPLY_WRAP_HPP_INCLUDED
Jeff Thompsona28eed82013-08-22 16:21:10 -070079
80///// iteration, depth == 1
81
82// For gcc 4.4 compatability, we must include the
Jeff Thompson3d613fd2013-10-15 15:39:04 -070083// NDNBOOST_PP_ITERATION_DEPTH test inside an #else clause.
84#else // NDNBOOST_PP_IS_ITERATING
85#if NDNBOOST_PP_ITERATION_DEPTH() == 1
Jeff Thompsona28eed82013-08-22 16:21:10 -070086
Jeff Thompson3d613fd2013-10-15 15:39:04 -070087# define i_ NDNBOOST_PP_FRAME_ITERATION(1)
Jeff Thompsona28eed82013-08-22 16:21:10 -070088
Jeff Thompson3d613fd2013-10-15 15:39:04 -070089# if NDNBOOST_WORKAROUND(NDNBOOST_MSVC, < 1300)
Jeff Thompsona28eed82013-08-22 16:21:10 -070090// MSVC version
91
Jeff Thompson3d613fd2013-10-15 15:39:04 -070092#define AUX778076_MSVC_DTW_NAME NDNBOOST_PP_CAT(msvc_apply,i_)
Jeff Thompsona28eed82013-08-22 16:21:10 -070093#define AUX778076_MSVC_DTW_ORIGINAL_NAME apply
94#define AUX778076_MSVC_DTW_ARITY i_
95#include <ndnboost/mpl/aux_/msvc_dtw.hpp>
96
97template<
Jeff Thompson3d613fd2013-10-15 15:39:04 -070098 typename F NDNBOOST_PP_COMMA_IF(i_) AUX778076_APPLY_WRAP_PARAMS(i_, typename T)
Jeff Thompsona28eed82013-08-22 16:21:10 -070099 >
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700100struct NDNBOOST_PP_CAT(apply_wrap,i_)
Jeff Thompsona28eed82013-08-22 16:21:10 -0700101{
102 // Metafunction forwarding confuses vc6
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700103 typedef typename NDNBOOST_PP_CAT(msvc_apply,i_)<F>::template result_<
Jeff Thompsona28eed82013-08-22 16:21:10 -0700104 AUX778076_APPLY_WRAP_PARAMS(i_, T)
105 >::type type;
106};
107
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700108# elif defined(NDNBOOST_MPL_CFG_BROKEN_DEFAULT_PARAMETERS_IN_NESTED_TEMPLATES)
Jeff Thompsona28eed82013-08-22 16:21:10 -0700109// MWCW/Borland version
110
111template<
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700112 int N, typename F NDNBOOST_PP_COMMA_IF(i_) AUX778076_APPLY_WRAP_PARAMS(i_, typename T)
Jeff Thompsona28eed82013-08-22 16:21:10 -0700113 >
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700114struct NDNBOOST_PP_CAT(apply_wrap_impl,i_);
Jeff Thompsona28eed82013-08-22 16:21:10 -0700115
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700116#define NDNBOOST_PP_ITERATION_PARAMS_2 \
117 (3,(0, NDNBOOST_MPL_LIMIT_METAFUNCTION_ARITY - i_, <ndnboost/mpl/apply_wrap.hpp>))
118#include NDNBOOST_PP_ITERATE()
Jeff Thompsona28eed82013-08-22 16:21:10 -0700119
120template<
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700121 typename F NDNBOOST_PP_COMMA_IF(i_) AUX778076_APPLY_WRAP_PARAMS(i_, typename T)
Jeff Thompsona28eed82013-08-22 16:21:10 -0700122 >
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700123struct NDNBOOST_PP_CAT(apply_wrap,i_)
124 : NDNBOOST_PP_CAT(apply_wrap_impl,i_)<
Jeff Thompsona28eed82013-08-22 16:21:10 -0700125 ::ndnboost::mpl::aux::arity<F,i_>::value
126 , F
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700127 NDNBOOST_PP_COMMA_IF(i_) AUX778076_APPLY_WRAP_PARAMS(i_, T)
Jeff Thompsona28eed82013-08-22 16:21:10 -0700128 >::type
129{
130};
131
132# else
133// ISO98 C++, with minor concession to vc7
134
135template<
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700136 typename F NDNBOOST_PP_COMMA_IF(i_) AUX778076_APPLY_WRAP_PARAMS(i_, typename T)
Jeff Thompsona28eed82013-08-22 16:21:10 -0700137#if i_ == 0
138 , typename has_apply_ = typename aux::has_apply<F>::type
139#endif
140 >
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700141struct NDNBOOST_PP_CAT(apply_wrap,i_)
Jeff Thompsona28eed82013-08-22 16:21:10 -0700142// metafunction forwarding confuses MSVC 7.0
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700143#if !NDNBOOST_WORKAROUND(NDNBOOST_MSVC, == 1300)
Jeff Thompsona28eed82013-08-22 16:21:10 -0700144 : F::template apply< AUX778076_APPLY_WRAP_PARAMS(i_, T) >
145{
146#else
147{
148 typedef typename F::template apply<
149 AUX778076_APPLY_WRAP_PARAMS(i_, T)
150 >::type type;
151#endif
152};
153
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700154#if i_ == 0 && !defined(NDNBOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
Jeff Thompsona28eed82013-08-22 16:21:10 -0700155template< typename F >
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700156struct NDNBOOST_PP_CAT(apply_wrap,i_)<F,true_>
Jeff Thompsona28eed82013-08-22 16:21:10 -0700157 : F::apply
158{
159};
160#endif
161
162# endif // workarounds
163
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700164#if defined(NDNBOOST_MPL_CFG_MSVC_ETI_BUG)
Jeff Thompsona28eed82013-08-22 16:21:10 -0700165/// workaround for ETI bug
166template<>
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700167struct NDNBOOST_PP_CAT(apply_wrap,i_)<AUX778076_APPLY_WRAP_SPEC_PARAMS(i_, int)>
Jeff Thompsona28eed82013-08-22 16:21:10 -0700168{
169 typedef int type;
170};
171#endif
172
173# undef i_
174
175///// iteration, depth == 2
176
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700177#elif NDNBOOST_PP_ITERATION_DEPTH() == 2
Jeff Thompsona28eed82013-08-22 16:21:10 -0700178
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700179# define j_ NDNBOOST_PP_FRAME_ITERATION(2)
Jeff Thompsona28eed82013-08-22 16:21:10 -0700180
181#if i_ == 0 && j_ == 0 \
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700182 && defined(NDNBOOST_MPL_CFG_BCC590_WORKAROUNDS) \
183 && !defined(NDNBOOST_MPL_CFG_NO_HAS_APPLY)
Jeff Thompsona28eed82013-08-22 16:21:10 -0700184
185template< typename F, bool F_has_apply >
186struct apply_wrap_impl0_bcb {
187 typedef typename F::template apply< na > type;
188};
189
190template< typename F >
191struct apply_wrap_impl0_bcb< F, true > {
192 typedef typename F::apply type;
193};
194
195template<
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700196 typename F NDNBOOST_PP_COMMA_IF(i_) AUX778076_APPLY_WRAP_PARAMS(i_, typename T)
Jeff Thompsona28eed82013-08-22 16:21:10 -0700197 >
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700198struct NDNBOOST_PP_CAT(apply_wrap_impl,i_)<
199 NDNBOOST_MPL_PP_ADD(i_, j_)
Jeff Thompsona28eed82013-08-22 16:21:10 -0700200 , F
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700201 NDNBOOST_PP_COMMA_IF(i_) AUX778076_APPLY_WRAP_PARAMS(i_, T)
Jeff Thompsona28eed82013-08-22 16:21:10 -0700202 >
203{
204 typedef apply_wrap_impl0_bcb< F, aux::has_apply< F >::value >::type type;
205};
206#else
207
208template<
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700209 typename F NDNBOOST_PP_COMMA_IF(i_) AUX778076_APPLY_WRAP_PARAMS(i_, typename T)
Jeff Thompsona28eed82013-08-22 16:21:10 -0700210 >
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700211struct NDNBOOST_PP_CAT(apply_wrap_impl,i_)<
212 NDNBOOST_MPL_PP_ADD(i_, j_)
Jeff Thompsona28eed82013-08-22 16:21:10 -0700213 , F
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700214 NDNBOOST_PP_COMMA_IF(i_) AUX778076_APPLY_WRAP_PARAMS(i_, T)
Jeff Thompsona28eed82013-08-22 16:21:10 -0700215 >
216{
217 typedef typename F::template apply<
218 AUX778076_APPLY_WRAP_PARAMS(i_, T)
219#if i_ == 0 && j_ == 0
220/// since the defaults are "lost", we have to pass *something* even for nullary
221/// metafunction classes
222 na
223#else
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700224 NDNBOOST_PP_COMMA_IF(NDNBOOST_PP_AND(i_, j_)) NDNBOOST_MPL_PP_ENUM(j_, na)
Jeff Thompsona28eed82013-08-22 16:21:10 -0700225#endif
226 > type;
227};
228
229#endif
230
231# undef j_
232
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700233#endif // NDNBOOST_PP_ITERATION_DEPTH()
234#endif // NDNBOOST_PP_IS_ITERATING