blob: aa08f983b7676208d839c83e5436a27cd3aaf719 [file] [log] [blame]
Jeff Thompsonf7d49942013-08-01 16:47:40 -07001
Jeff Thompson3d613fd2013-10-15 15:39:04 -07002#ifndef NDNBOOST_MPL_AUX_LAMBDA_SUPPORT_HPP_INCLUDED
3#define NDNBOOST_MPL_AUX_LAMBDA_SUPPORT_HPP_INCLUDED
Jeff Thompsonf7d49942013-08-01 16:47:40 -07004
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
Jeff Thompson3d613fd2013-10-15 15:39:04 -070019#if !defined(NDNBOOST_MPL_CFG_NO_FULL_LAMBDA_SUPPORT)
Jeff Thompsonf7d49942013-08-01 16:47:40 -070020
Jeff Thompson3d613fd2013-10-15 15:39:04 -070021# define NDNBOOST_MPL_AUX_LAMBDA_SUPPORT_SPEC(i, name, params) /**/
22# define NDNBOOST_MPL_AUX_LAMBDA_SUPPORT(i,name,params) /**/
Jeff Thompsonf7d49942013-08-01 16:47:40 -070023
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
Jeff Thompson3d613fd2013-10-15 15:39:04 -070039# define NDNBOOST_MPL_AUX_LAMBDA_SUPPORT_ARG_TYPEDEF_FUNC(R,typedef_,i,param) \
40 typedef_ param NDNBOOST_PP_CAT(arg,NDNBOOST_PP_INC(i)); \
Jeff Thompsonf7d49942013-08-01 16:47:40 -070041 /**/
42
43// agurt, 07/mar/03: restore an old revision for the sake of SGI MIPSpro C++
Jeff Thompson3d613fd2013-10-15 15:39:04 -070044#if NDNBOOST_WORKAROUND(__EDG_VERSION__, <= 238)
Jeff Thompsonf7d49942013-08-01 16:47:40 -070045
Jeff Thompson3d613fd2013-10-15 15:39:04 -070046# define NDNBOOST_MPL_AUX_LAMBDA_SUPPORT(i, name, params) \
47 typedef NDNBOOST_MPL_AUX_ADL_BARRIER_NAMESPACE::int_<i> arity; \
48 NDNBOOST_PP_LIST_FOR_EACH_I_R( \
Jeff Thompsonf7d49942013-08-01 16:47:40 -070049 1 \
Jeff Thompson3d613fd2013-10-15 15:39:04 -070050 , NDNBOOST_MPL_AUX_LAMBDA_SUPPORT_ARG_TYPEDEF_FUNC \
Jeff Thompsonf7d49942013-08-01 16:47:40 -070051 , typedef \
Jeff Thompson3d613fd2013-10-15 15:39:04 -070052 , NDNBOOST_PP_TUPLE_TO_LIST(i,params) \
Jeff Thompsonf7d49942013-08-01 16:47:40 -070053 ) \
54 struct rebind \
55 { \
Jeff Thompson3d613fd2013-10-15 15:39:04 -070056 template< NDNBOOST_MPL_PP_PARAMS(i,typename U) > struct apply \
57 : name< NDNBOOST_MPL_PP_PARAMS(i,U) > \
Jeff Thompsonf7d49942013-08-01 16:47:40 -070058 { \
59 }; \
60 }; \
61 /**/
62
Jeff Thompson3d613fd2013-10-15 15:39:04 -070063# define NDNBOOST_MPL_AUX_LAMBDA_SUPPORT_SPEC(i, name, params) \
64 NDNBOOST_MPL_AUX_LAMBDA_SUPPORT(i, name, params) \
Jeff Thompsonf7d49942013-08-01 16:47:40 -070065 /**/
66
Jeff Thompson3d613fd2013-10-15 15:39:04 -070067#elif NDNBOOST_WORKAROUND(__EDG_VERSION__, <= 244) && !defined(NDNBOOST_INTEL_CXX_VERSION)
Jeff Thompsonf7d49942013-08-01 16:47:40 -070068// 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
Jeff Thompson3d613fd2013-10-15 15:39:04 -070072# define NDNBOOST_MPL_AUX_LAMBDA_SUPPORT_SPEC(i, name, params) \
73 typedef NDNBOOST_MPL_AUX_ADL_BARRIER_NAMESPACE::int_<i> arity; \
74 NDNBOOST_PP_LIST_FOR_EACH_I_R( \
Jeff Thompsonf7d49942013-08-01 16:47:40 -070075 1 \
Jeff Thompson3d613fd2013-10-15 15:39:04 -070076 , NDNBOOST_MPL_AUX_LAMBDA_SUPPORT_ARG_TYPEDEF_FUNC \
Jeff Thompsonf7d49942013-08-01 16:47:40 -070077 , typedef \
Jeff Thompson3d613fd2013-10-15 15:39:04 -070078 , NDNBOOST_PP_TUPLE_TO_LIST(i,params) \
Jeff Thompsonf7d49942013-08-01 16:47:40 -070079 ) \
80 struct rebind; \
81/**/
82
Jeff Thompson3d613fd2013-10-15 15:39:04 -070083# define NDNBOOST_MPL_AUX_LAMBDA_SUPPORT(i, name, params) \
84 NDNBOOST_MPL_AUX_LAMBDA_SUPPORT_SPEC(i, name, params) \
Jeff Thompsonf7d49942013-08-01 16:47:40 -070085}; \
Jeff Thompson3d613fd2013-10-15 15:39:04 -070086template< NDNBOOST_MPL_PP_PARAMS(i,typename T) > \
87struct name<NDNBOOST_MPL_PP_PARAMS(i,T)>::rebind \
Jeff Thompsonf7d49942013-08-01 16:47:40 -070088{ \
Jeff Thompson3d613fd2013-10-15 15:39:04 -070089 template< NDNBOOST_MPL_PP_PARAMS(i,typename U) > struct apply \
90 : name< NDNBOOST_MPL_PP_PARAMS(i,U) > \
Jeff Thompsonf7d49942013-08-01 16:47:40 -070091 { \
92 }; \
93/**/
94
95#else // __EDG_VERSION__
96
97namespace ndnboost { namespace mpl { namespace aux {
98template< typename T > struct has_rebind_tag;
99}}}
100
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700101# define NDNBOOST_MPL_AUX_LAMBDA_SUPPORT_SPEC(i, name, params) \
102 typedef NDNBOOST_MPL_AUX_ADL_BARRIER_NAMESPACE::int_<i> arity; \
103 NDNBOOST_PP_LIST_FOR_EACH_I_R( \
Jeff Thompsonf7d49942013-08-01 16:47:40 -0700104 1 \
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700105 , NDNBOOST_MPL_AUX_LAMBDA_SUPPORT_ARG_TYPEDEF_FUNC \
Jeff Thompsonf7d49942013-08-01 16:47:40 -0700106 , typedef \
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700107 , NDNBOOST_PP_TUPLE_TO_LIST(i,params) \
Jeff Thompsonf7d49942013-08-01 16:47:40 -0700108 ) \
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700109 friend class NDNBOOST_PP_CAT(name,_rebind); \
110 typedef NDNBOOST_PP_CAT(name,_rebind) rebind; \
Jeff Thompsonf7d49942013-08-01 16:47:40 -0700111/**/
112
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700113#if NDNBOOST_WORKAROUND(__BORLANDC__, NDNBOOST_TESTED_AT(0x610))
114# define NDNBOOST_MPL_AUX_LAMBDA_SUPPORT_HAS_REBIND(i, name, params) \
115template< NDNBOOST_MPL_PP_PARAMS(i,typename T) > \
Jeff Thompsonf7d49942013-08-01 16:47:40 -0700116::ndnboost::mpl::aux::yes_tag operator|( \
117 ::ndnboost::mpl::aux::has_rebind_tag<int> \
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700118 , name<NDNBOOST_MPL_PP_PARAMS(i,T)>* \
Jeff Thompsonf7d49942013-08-01 16:47:40 -0700119 ); \
120::ndnboost::mpl::aux::no_tag operator|( \
121 ::ndnboost::mpl::aux::has_rebind_tag<int> \
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700122 , name< NDNBOOST_MPL_PP_ENUM(i,::ndnboost::mpl::na) >* \
Jeff Thompsonf7d49942013-08-01 16:47:40 -0700123 ); \
124/**/
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700125#elif !NDNBOOST_WORKAROUND(NDNBOOST_MSVC, < 1300)
126# define NDNBOOST_MPL_AUX_LAMBDA_SUPPORT_HAS_REBIND(i, name, params) \
127template< NDNBOOST_MPL_PP_PARAMS(i,typename T) > \
Jeff Thompsonf7d49942013-08-01 16:47:40 -0700128::ndnboost::mpl::aux::yes_tag operator|( \
129 ::ndnboost::mpl::aux::has_rebind_tag<int> \
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700130 , ::ndnboost::mpl::aux::has_rebind_tag< name<NDNBOOST_MPL_PP_PARAMS(i,T)> >* \
Jeff Thompsonf7d49942013-08-01 16:47:40 -0700131 ); \
132/**/
133#else
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700134# define NDNBOOST_MPL_AUX_LAMBDA_SUPPORT_HAS_REBIND(i, name, params) /**/
Jeff Thompsonf7d49942013-08-01 16:47:40 -0700135#endif
136
137# if !defined(__BORLANDC__)
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700138# define NDNBOOST_MPL_AUX_LAMBDA_SUPPORT(i, name, params) \
139 NDNBOOST_MPL_AUX_LAMBDA_SUPPORT_SPEC(i, name, params) \
Jeff Thompsonf7d49942013-08-01 16:47:40 -0700140}; \
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700141NDNBOOST_MPL_AUX_LAMBDA_SUPPORT_HAS_REBIND(i, name, params) \
142class NDNBOOST_PP_CAT(name,_rebind) \
Jeff Thompsonf7d49942013-08-01 16:47:40 -0700143{ \
144 public: \
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700145 template< NDNBOOST_MPL_PP_PARAMS(i,typename U) > struct apply \
146 : name< NDNBOOST_MPL_PP_PARAMS(i,U) > \
Jeff Thompsonf7d49942013-08-01 16:47:40 -0700147 { \
148 }; \
149/**/
150# else
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700151# define NDNBOOST_MPL_AUX_LAMBDA_SUPPORT(i, name, params) \
152 NDNBOOST_MPL_AUX_LAMBDA_SUPPORT_SPEC(i, name, params) \
Jeff Thompsonf7d49942013-08-01 16:47:40 -0700153}; \
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700154NDNBOOST_MPL_AUX_LAMBDA_SUPPORT_HAS_REBIND(i, name, params) \
155class NDNBOOST_PP_CAT(name,_rebind) \
Jeff Thompsonf7d49942013-08-01 16:47:40 -0700156{ \
157 public: \
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700158 template< NDNBOOST_MPL_PP_PARAMS(i,typename U) > struct apply \
Jeff Thompsonf7d49942013-08-01 16:47:40 -0700159 { \
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700160 typedef typename name< NDNBOOST_MPL_PP_PARAMS(i,U) >::type type; \
Jeff Thompsonf7d49942013-08-01 16:47:40 -0700161 }; \
162/**/
163# endif // __BORLANDC__
164
165#endif // __EDG_VERSION__
166
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700167#endif // NDNBOOST_MPL_CFG_NO_FULL_LAMBDA_SUPPORT
Jeff Thompsonf7d49942013-08-01 16:47:40 -0700168
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700169#endif // NDNBOOST_MPL_AUX_LAMBDA_SUPPORT_HPP_INCLUDED