blob: 955b155c06b04a8b867862f6f61d51cc2998a944 [file] [log] [blame]
Jeff Thompsonf7d49942013-08-01 16:47:40 -07001
2#ifndef BOOST_MPL_AUX_LAMBDA_SUPPORT_HPP_INCLUDED
3#define BOOST_MPL_AUX_LAMBDA_SUPPORT_HPP_INCLUDED
4
5// Copyright Aleksey Gurtovoy 2001-2004
6//
7// Distributed under the Boost Software License, Version 1.0.
8// (See accompanying file LICENSE_1_0.txt or copy at
9// http://www.boost.org/LICENSE_1_0.txt)
10//
11// See http://www.boost.org/libs/mpl for documentation.
12
13// $Id: lambda_support.hpp 49267 2008-10-11 06:19:02Z agurtovoy $
14// $Date: 2008-10-10 23:19:02 -0700 (Fri, 10 Oct 2008) $
15// $Revision: 49267 $
16
Jeff Thompson2277ce52013-08-01 17:34:11 -070017#include <ndnboost/mpl/aux_/config/lambda.hpp>
Jeff Thompsonf7d49942013-08-01 16:47:40 -070018
19#if !defined(BOOST_MPL_CFG_NO_FULL_LAMBDA_SUPPORT)
20
21# define BOOST_MPL_AUX_LAMBDA_SUPPORT_SPEC(i, name, params) /**/
22# define BOOST_MPL_AUX_LAMBDA_SUPPORT(i,name,params) /**/
23
24#else
25
Jeff Thompson2277ce52013-08-01 17:34:11 -070026# include <ndnboost/mpl/int_fwd.hpp>
27# include <ndnboost/mpl/aux_/yes_no.hpp>
28# include <ndnboost/mpl/aux_/na_fwd.hpp>
29# include <ndnboost/mpl/aux_/preprocessor/params.hpp>
30# include <ndnboost/mpl/aux_/preprocessor/enum.hpp>
31# include <ndnboost/mpl/aux_/config/msvc.hpp>
32# include <ndnboost/mpl/aux_/config/workaround.hpp>
Jeff Thompsonf7d49942013-08-01 16:47:40 -070033
Jeff Thompson2277ce52013-08-01 17:34:11 -070034# include <ndnboost/preprocessor/tuple/to_list.hpp>
35# include <ndnboost/preprocessor/list/for_each_i.hpp>
36# include <ndnboost/preprocessor/inc.hpp>
37# include <ndnboost/preprocessor/cat.hpp>
Jeff Thompsonf7d49942013-08-01 16:47:40 -070038
39# define BOOST_MPL_AUX_LAMBDA_SUPPORT_ARG_TYPEDEF_FUNC(R,typedef_,i,param) \
40 typedef_ param BOOST_PP_CAT(arg,BOOST_PP_INC(i)); \
41 /**/
42
43// agurt, 07/mar/03: restore an old revision for the sake of SGI MIPSpro C++
44#if BOOST_WORKAROUND(__EDG_VERSION__, <= 238)
45
46# define BOOST_MPL_AUX_LAMBDA_SUPPORT(i, name, params) \
47 typedef BOOST_MPL_AUX_ADL_BARRIER_NAMESPACE::int_<i> arity; \
48 BOOST_PP_LIST_FOR_EACH_I_R( \
49 1 \
50 , BOOST_MPL_AUX_LAMBDA_SUPPORT_ARG_TYPEDEF_FUNC \
51 , typedef \
52 , BOOST_PP_TUPLE_TO_LIST(i,params) \
53 ) \
54 struct rebind \
55 { \
56 template< BOOST_MPL_PP_PARAMS(i,typename U) > struct apply \
57 : name< BOOST_MPL_PP_PARAMS(i,U) > \
58 { \
59 }; \
60 }; \
61 /**/
62
63# define BOOST_MPL_AUX_LAMBDA_SUPPORT_SPEC(i, name, params) \
64 BOOST_MPL_AUX_LAMBDA_SUPPORT(i, name, params) \
65 /**/
66
67#elif BOOST_WORKAROUND(__EDG_VERSION__, <= 244) && !defined(BOOST_INTEL_CXX_VERSION)
68// agurt, 18/jan/03: old EDG-based compilers actually enforce 11.4 para 9
69// (in strict mode), so we have to provide an alternative to the
70// MSVC-optimized implementation
71
72# define BOOST_MPL_AUX_LAMBDA_SUPPORT_SPEC(i, name, params) \
73 typedef BOOST_MPL_AUX_ADL_BARRIER_NAMESPACE::int_<i> arity; \
74 BOOST_PP_LIST_FOR_EACH_I_R( \
75 1 \
76 , BOOST_MPL_AUX_LAMBDA_SUPPORT_ARG_TYPEDEF_FUNC \
77 , typedef \
78 , BOOST_PP_TUPLE_TO_LIST(i,params) \
79 ) \
80 struct rebind; \
81/**/
82
83# define BOOST_MPL_AUX_LAMBDA_SUPPORT(i, name, params) \
84 BOOST_MPL_AUX_LAMBDA_SUPPORT_SPEC(i, name, params) \
85}; \
86template< BOOST_MPL_PP_PARAMS(i,typename T) > \
87struct name<BOOST_MPL_PP_PARAMS(i,T)>::rebind \
88{ \
89 template< BOOST_MPL_PP_PARAMS(i,typename U) > struct apply \
90 : name< BOOST_MPL_PP_PARAMS(i,U) > \
91 { \
92 }; \
93/**/
94
95#else // __EDG_VERSION__
96
97namespace ndnboost { namespace mpl { namespace aux {
98template< typename T > struct has_rebind_tag;
99}}}
100
101# define BOOST_MPL_AUX_LAMBDA_SUPPORT_SPEC(i, name, params) \
102 typedef BOOST_MPL_AUX_ADL_BARRIER_NAMESPACE::int_<i> arity; \
103 BOOST_PP_LIST_FOR_EACH_I_R( \
104 1 \
105 , BOOST_MPL_AUX_LAMBDA_SUPPORT_ARG_TYPEDEF_FUNC \
106 , typedef \
107 , BOOST_PP_TUPLE_TO_LIST(i,params) \
108 ) \
109 friend class BOOST_PP_CAT(name,_rebind); \
110 typedef BOOST_PP_CAT(name,_rebind) rebind; \
111/**/
112
113#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x610))
114# define BOOST_MPL_AUX_LAMBDA_SUPPORT_HAS_REBIND(i, name, params) \
115template< BOOST_MPL_PP_PARAMS(i,typename T) > \
116::ndnboost::mpl::aux::yes_tag operator|( \
117 ::ndnboost::mpl::aux::has_rebind_tag<int> \
118 , name<BOOST_MPL_PP_PARAMS(i,T)>* \
119 ); \
120::ndnboost::mpl::aux::no_tag operator|( \
121 ::ndnboost::mpl::aux::has_rebind_tag<int> \
122 , name< BOOST_MPL_PP_ENUM(i,::ndnboost::mpl::na) >* \
123 ); \
124/**/
125#elif !BOOST_WORKAROUND(BOOST_MSVC, < 1300)
126# define BOOST_MPL_AUX_LAMBDA_SUPPORT_HAS_REBIND(i, name, params) \
127template< BOOST_MPL_PP_PARAMS(i,typename T) > \
128::ndnboost::mpl::aux::yes_tag operator|( \
129 ::ndnboost::mpl::aux::has_rebind_tag<int> \
130 , ::ndnboost::mpl::aux::has_rebind_tag< name<BOOST_MPL_PP_PARAMS(i,T)> >* \
131 ); \
132/**/
133#else
134# define BOOST_MPL_AUX_LAMBDA_SUPPORT_HAS_REBIND(i, name, params) /**/
135#endif
136
137# if !defined(__BORLANDC__)
138# define BOOST_MPL_AUX_LAMBDA_SUPPORT(i, name, params) \
139 BOOST_MPL_AUX_LAMBDA_SUPPORT_SPEC(i, name, params) \
140}; \
141BOOST_MPL_AUX_LAMBDA_SUPPORT_HAS_REBIND(i, name, params) \
142class BOOST_PP_CAT(name,_rebind) \
143{ \
144 public: \
145 template< BOOST_MPL_PP_PARAMS(i,typename U) > struct apply \
146 : name< BOOST_MPL_PP_PARAMS(i,U) > \
147 { \
148 }; \
149/**/
150# else
151# define BOOST_MPL_AUX_LAMBDA_SUPPORT(i, name, params) \
152 BOOST_MPL_AUX_LAMBDA_SUPPORT_SPEC(i, name, params) \
153}; \
154BOOST_MPL_AUX_LAMBDA_SUPPORT_HAS_REBIND(i, name, params) \
155class BOOST_PP_CAT(name,_rebind) \
156{ \
157 public: \
158 template< BOOST_MPL_PP_PARAMS(i,typename U) > struct apply \
159 { \
160 typedef typename name< BOOST_MPL_PP_PARAMS(i,U) >::type type; \
161 }; \
162/**/
163# endif // __BORLANDC__
164
165#endif // __EDG_VERSION__
166
167#endif // BOOST_MPL_CFG_NO_FULL_LAMBDA_SUPPORT
168
169#endif // BOOST_MPL_AUX_LAMBDA_SUPPORT_HPP_INCLUDED