blob: 8da4714ef97c5ceb4f88889415a6805c06b03a3d [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_AUX_LAMBDA_NO_CTPS_HPP_INCLUDED
7#define NDNBOOST_MPL_AUX_LAMBDA_NO_CTPS_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: lambda_no_ctps.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/lambda_fwd.hpp>
23# include <ndnboost/mpl/bind_fwd.hpp>
24# include <ndnboost/mpl/protect.hpp>
25# include <ndnboost/mpl/is_placeholder.hpp>
26# include <ndnboost/mpl/if.hpp>
27# include <ndnboost/mpl/identity.hpp>
28# include <ndnboost/mpl/bool.hpp>
29# include <ndnboost/mpl/aux_/na_spec.hpp>
30# include <ndnboost/mpl/aux_/lambda_support.hpp>
31# include <ndnboost/mpl/aux_/template_arity.hpp>
32# include <ndnboost/mpl/aux_/value_wknd.hpp>
33#endif
34
35#include <ndnboost/mpl/aux_/config/use_preprocessed.hpp>
36
Jeff Thompson3d613fd2013-10-15 15:39:04 -070037#if !defined(NDNBOOST_MPL_CFG_NO_PREPROCESSED_HEADERS) \
38 && !defined(NDNBOOST_MPL_PREPROCESSING_MODE)
Jeff Thompsona28eed82013-08-22 16:21:10 -070039
Jeff Thompson3d613fd2013-10-15 15:39:04 -070040# define NDNBOOST_MPL_PREPROCESSED_HEADER lambda_no_ctps.hpp
Jeff Thompsona28eed82013-08-22 16:21:10 -070041# include <ndnboost/mpl/aux_/include_preprocessed.hpp>
42
43#else
44
45# include <ndnboost/mpl/limits/arity.hpp>
46# include <ndnboost/mpl/aux_/preprocessor/params.hpp>
47# include <ndnboost/mpl/aux_/preprocessor/default_params.hpp>
48# include <ndnboost/mpl/aux_/preprocessor/repeat.hpp>
49# include <ndnboost/mpl/aux_/preprocessor/enum.hpp>
50# include <ndnboost/mpl/aux_/config/msvc.hpp>
51# include <ndnboost/mpl/aux_/config/workaround.hpp>
52
53# include <ndnboost/preprocessor/comma_if.hpp>
54# include <ndnboost/preprocessor/iterate.hpp>
55# include <ndnboost/preprocessor/inc.hpp>
56# include <ndnboost/preprocessor/cat.hpp>
57
58namespace ndnboost { namespace mpl {
59
60# define AUX778076_LAMBDA_PARAMS(i_, param) \
Jeff Thompson3d613fd2013-10-15 15:39:04 -070061 NDNBOOST_MPL_PP_PARAMS(i_, param) \
Jeff Thompsona28eed82013-08-22 16:21:10 -070062 /**/
63
64namespace aux {
65
Jeff Thompson3d613fd2013-10-15 15:39:04 -070066#define n_ NDNBOOST_MPL_LIMIT_METAFUNCTION_ARITY
Jeff Thompsona28eed82013-08-22 16:21:10 -070067template<
Jeff Thompson3d613fd2013-10-15 15:39:04 -070068 NDNBOOST_MPL_PP_DEFAULT_PARAMS(n_,bool C,false)
Jeff Thompsona28eed82013-08-22 16:21:10 -070069 >
70struct lambda_or
71 : true_
72{
73};
74
75template<>
Jeff Thompson3d613fd2013-10-15 15:39:04 -070076struct lambda_or< NDNBOOST_MPL_PP_ENUM(n_,false) >
Jeff Thompsona28eed82013-08-22 16:21:10 -070077 : false_
78{
79};
80#undef n_
81
82template< typename Arity > struct lambda_impl
83{
84 template< typename T, typename Tag, typename Protect > struct result_
85 {
86 typedef T type;
87 typedef is_placeholder<T> is_le;
88 };
89};
90
Jeff Thompson3d613fd2013-10-15 15:39:04 -070091#define NDNBOOST_PP_ITERATION_PARAMS_1 \
92 (3,(1, NDNBOOST_MPL_LIMIT_METAFUNCTION_ARITY, <ndnboost/mpl/aux_/lambda_no_ctps.hpp>))
93#include NDNBOOST_PP_ITERATE()
Jeff Thompsona28eed82013-08-22 16:21:10 -070094
95} // namespace aux
96
97template<
98 typename T
99 , typename Tag
100 , typename Protect
101 >
102struct lambda
103{
104 /// Metafunction forwarding confuses MSVC 6.x
105 typedef typename aux::template_arity<T>::type arity_;
106 typedef typename aux::lambda_impl<arity_>
107 ::template result_< T,Tag,Protect > l_;
108
109 typedef typename l_::type type;
110 typedef typename l_::is_le is_le;
111
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700112 NDNBOOST_MPL_AUX_LAMBDA_SUPPORT(3, lambda, (T, Tag, Protect))
Jeff Thompsona28eed82013-08-22 16:21:10 -0700113};
114
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700115NDNBOOST_MPL_AUX_NA_SPEC2(1, 3, lambda)
Jeff Thompsona28eed82013-08-22 16:21:10 -0700116
117template<
118 typename T
119 >
120struct is_lambda_expression
121 : lambda<T>::is_le
122{
123};
124
125# undef AUX778076_LAMBDA_PARAMS
126
127}}
128
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700129#endif // NDNBOOST_MPL_CFG_NO_PREPROCESSED_HEADERS
130#endif // NDNBOOST_MPL_AUX_LAMBDA_NO_CTPS_HPP_INCLUDED
Jeff Thompsona28eed82013-08-22 16:21:10 -0700131
132///// iteration, depth == 1
133
134#else
135
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700136#define i_ NDNBOOST_PP_FRAME_ITERATION(1)
Jeff Thompsona28eed82013-08-22 16:21:10 -0700137
138# define AUX778076_LAMBDA_TYPEDEF(unused, i_, F) \
139 typedef lambda< \
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700140 typename F::NDNBOOST_PP_CAT(arg,NDNBOOST_PP_INC(i_)) \
Jeff Thompsona28eed82013-08-22 16:21:10 -0700141 , Tag \
142 , false_ \
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700143 > NDNBOOST_PP_CAT(l,NDNBOOST_PP_INC(i_)); \
Jeff Thompsona28eed82013-08-22 16:21:10 -0700144 /**/
145
146# define AUX778076_IS_LE_TYPEDEF(unused, i_, unused2) \
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700147 typedef typename NDNBOOST_PP_CAT(l,NDNBOOST_PP_INC(i_))::is_le \
148 NDNBOOST_PP_CAT(is_le,NDNBOOST_PP_INC(i_)); \
Jeff Thompsona28eed82013-08-22 16:21:10 -0700149 /**/
150
151# define AUX778076_IS_LAMBDA_EXPR(unused, i_, unused2) \
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700152 NDNBOOST_PP_COMMA_IF(i_) \
153 NDNBOOST_MPL_AUX_MSVC_VALUE_WKND(NDNBOOST_PP_CAT(is_le,NDNBOOST_PP_INC(i_)))::value \
Jeff Thompsona28eed82013-08-22 16:21:10 -0700154 /**/
155
156# define AUX778076_LAMBDA_RESULT(unused, i_, unused2) \
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700157 , typename NDNBOOST_PP_CAT(l,NDNBOOST_PP_INC(i_))::type \
Jeff Thompsona28eed82013-08-22 16:21:10 -0700158 /**/
159
160template<> struct lambda_impl< int_<i_> >
161{
162 template< typename F, typename Tag, typename Protect > struct result_
163 {
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700164 NDNBOOST_MPL_PP_REPEAT(i_, AUX778076_LAMBDA_TYPEDEF, F)
165 NDNBOOST_MPL_PP_REPEAT(i_, AUX778076_IS_LE_TYPEDEF, unused)
Jeff Thompsona28eed82013-08-22 16:21:10 -0700166
167 typedef aux::lambda_or<
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700168 NDNBOOST_MPL_PP_REPEAT(i_, AUX778076_IS_LAMBDA_EXPR, unused)
Jeff Thompsona28eed82013-08-22 16:21:10 -0700169 > is_le;
170
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700171 typedef NDNBOOST_PP_CAT(bind,i_)<
Jeff Thompsona28eed82013-08-22 16:21:10 -0700172 typename F::rebind
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700173 NDNBOOST_MPL_PP_REPEAT(i_, AUX778076_LAMBDA_RESULT, unused)
Jeff Thompsona28eed82013-08-22 16:21:10 -0700174 > bind_;
175
176 typedef typename if_<
177 is_le
178 , if_< Protect, mpl::protect<bind_>, bind_ >
179 , identity<F>
180 >::type type_;
181
182 typedef typename type_::type type;
183 };
184};
185
186# undef AUX778076_LAMBDA_RESULT
187# undef AUX778076_IS_LAMBDA_EXPR
188# undef AUX778076_IS_LE_TYPEDEF
189# undef AUX778076_LAMBDA_TYPEDEF
190
191#undef i_
192
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700193#endif // NDNBOOST_PP_IS_ITERATING