blob: 568847ec32ec6e9ce12a0dea34fbd548adf73b08 [file] [log] [blame]
Jeff Thompsonf7d49942013-08-01 16:47:40 -07001
2// NO INCLUDE GUARDS, THE HEADER IS INTENDED FOR MULTIPLE INCLUSION
3
4// Copyright Aleksey Gurtovoy 2002-2004
5//
6// Distributed under the Boost Software License, Version 1.0.
7// (See accompanying file LICENSE_1_0.txt or copy at
8// http://www.boost.org/LICENSE_1_0.txt)
9
10// $Source$
11// $Date: 2011-10-09 15:28:33 -0700 (Sun, 09 Oct 2011) $
12// $Revision: 74865 $
13
Jeff Thompson2277ce52013-08-01 17:34:11 -070014#include <ndnboost/type_traits/detail/template_arity_spec.hpp>
15#include <ndnboost/type_traits/integral_constant.hpp>
16#include <ndnboost/mpl/bool.hpp>
17#include <ndnboost/mpl/aux_/lambda_support.hpp>
18#include <ndnboost/config.hpp>
Jeff Thompsonf7d49942013-08-01 16:47:40 -070019
20//
21// Unfortunately some libraries have started using this header without
22// cleaning up afterwards: so we'd better undef the macros just in case
23// they've been defined already....
24//
Jeff Thompson3d613fd2013-10-15 15:39:04 -070025#ifdef NDNBOOST_TT_AUX_BOOL_TRAIT_VALUE_DECL
26#undef NDNBOOST_TT_AUX_BOOL_TRAIT_VALUE_DECL
27#undef NDNBOOST_TT_AUX_BOOL_C_BASE
28#undef NDNBOOST_TT_AUX_BOOL_TRAIT_DEF1
29#undef NDNBOOST_TT_AUX_BOOL_TRAIT_DEF2
30#undef NDNBOOST_TT_AUX_BOOL_TRAIT_SPEC1
31#undef NDNBOOST_TT_AUX_BOOL_TRAIT_SPEC2
32#undef NDNBOOST_TT_AUX_BOOL_TRAIT_IMPL_SPEC1
33#undef NDNBOOST_TT_AUX_BOOL_TRAIT_IMPL_SPEC2
34#undef NDNBOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC1_1
35#undef NDNBOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC1_2
36#undef NDNBOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC2_1
37#undef NDNBOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC2_2
38#undef NDNBOOST_TT_AUX_BOOL_TRAIT_IMPL_PARTIAL_SPEC2_1
39#undef NDNBOOST_TT_AUX_BOOL_TRAIT_CV_SPEC1
Jeff Thompsonf7d49942013-08-01 16:47:40 -070040#endif
41
42#if defined(__SUNPRO_CC) && (__SUNPRO_CC < 0x570)
Jeff Thompson3d613fd2013-10-15 15:39:04 -070043# define NDNBOOST_TT_AUX_BOOL_TRAIT_VALUE_DECL(C) \
Jeff Thompsonf7d49942013-08-01 16:47:40 -070044 typedef ::ndnboost::integral_constant<bool,C> type; \
45 enum { value = type::value }; \
46 /**/
Jeff Thompson3d613fd2013-10-15 15:39:04 -070047# define NDNBOOST_TT_AUX_BOOL_C_BASE(C)
Jeff Thompsonf7d49942013-08-01 16:47:40 -070048
Jeff Thompson3d613fd2013-10-15 15:39:04 -070049#elif defined(NDNBOOST_MSVC) && NDNBOOST_MSVC < 1300
Jeff Thompsonf7d49942013-08-01 16:47:40 -070050
Jeff Thompson3d613fd2013-10-15 15:39:04 -070051# define NDNBOOST_TT_AUX_BOOL_TRAIT_VALUE_DECL(C) \
Jeff Thompsonf7d49942013-08-01 16:47:40 -070052 typedef ::ndnboost::integral_constant<bool,C> base_; \
53 using base_::value; \
54 /**/
55
56#endif
57
Jeff Thompson3d613fd2013-10-15 15:39:04 -070058#ifndef NDNBOOST_TT_AUX_BOOL_TRAIT_VALUE_DECL
59# define NDNBOOST_TT_AUX_BOOL_TRAIT_VALUE_DECL(C) /**/
Jeff Thompsonf7d49942013-08-01 16:47:40 -070060#endif
61
Jeff Thompson3d613fd2013-10-15 15:39:04 -070062#ifndef NDNBOOST_TT_AUX_BOOL_C_BASE
63# define NDNBOOST_TT_AUX_BOOL_C_BASE(C) : public ::ndnboost::integral_constant<bool,C>
Jeff Thompsonf7d49942013-08-01 16:47:40 -070064#endif
65
66
Jeff Thompson3d613fd2013-10-15 15:39:04 -070067#define NDNBOOST_TT_AUX_BOOL_TRAIT_DEF1(trait,T,C) \
Jeff Thompsonf7d49942013-08-01 16:47:40 -070068template< typename T > struct trait \
Jeff Thompson3d613fd2013-10-15 15:39:04 -070069 NDNBOOST_TT_AUX_BOOL_C_BASE(C) \
Jeff Thompsonf7d49942013-08-01 16:47:40 -070070{ \
71public:\
Jeff Thompson3d613fd2013-10-15 15:39:04 -070072 NDNBOOST_TT_AUX_BOOL_TRAIT_VALUE_DECL(C) \
73 NDNBOOST_MPL_AUX_LAMBDA_SUPPORT(1,trait,(T)) \
Jeff Thompsonf7d49942013-08-01 16:47:40 -070074}; \
75\
Jeff Thompson3d613fd2013-10-15 15:39:04 -070076NDNBOOST_TT_AUX_TEMPLATE_ARITY_SPEC(1,trait) \
Jeff Thompsonf7d49942013-08-01 16:47:40 -070077/**/
78
79
Jeff Thompson3d613fd2013-10-15 15:39:04 -070080#define NDNBOOST_TT_AUX_BOOL_TRAIT_DEF2(trait,T1,T2,C) \
Jeff Thompsonf7d49942013-08-01 16:47:40 -070081template< typename T1, typename T2 > struct trait \
Jeff Thompson3d613fd2013-10-15 15:39:04 -070082 NDNBOOST_TT_AUX_BOOL_C_BASE(C) \
Jeff Thompsonf7d49942013-08-01 16:47:40 -070083{ \
84public:\
Jeff Thompson3d613fd2013-10-15 15:39:04 -070085 NDNBOOST_TT_AUX_BOOL_TRAIT_VALUE_DECL(C) \
86 NDNBOOST_MPL_AUX_LAMBDA_SUPPORT(2,trait,(T1,T2)) \
Jeff Thompsonf7d49942013-08-01 16:47:40 -070087}; \
88\
Jeff Thompson3d613fd2013-10-15 15:39:04 -070089NDNBOOST_TT_AUX_TEMPLATE_ARITY_SPEC(2,trait) \
Jeff Thompsonf7d49942013-08-01 16:47:40 -070090/**/
91
Jeff Thompson3d613fd2013-10-15 15:39:04 -070092#define NDNBOOST_TT_AUX_BOOL_TRAIT_DEF3(trait,T1,T2,T3,C) \
Jeff Thompsonf7d49942013-08-01 16:47:40 -070093template< typename T1, typename T2, typename T3 > struct trait \
Jeff Thompson3d613fd2013-10-15 15:39:04 -070094 NDNBOOST_TT_AUX_BOOL_C_BASE(C) \
Jeff Thompsonf7d49942013-08-01 16:47:40 -070095{ \
96public:\
Jeff Thompson3d613fd2013-10-15 15:39:04 -070097 NDNBOOST_TT_AUX_BOOL_TRAIT_VALUE_DECL(C) \
98 NDNBOOST_MPL_AUX_LAMBDA_SUPPORT(3,trait,(T1,T2,T3)) \
Jeff Thompsonf7d49942013-08-01 16:47:40 -070099}; \
100\
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700101NDNBOOST_TT_AUX_TEMPLATE_ARITY_SPEC(3,trait) \
Jeff Thompsonf7d49942013-08-01 16:47:40 -0700102/**/
103
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700104#define NDNBOOST_TT_AUX_BOOL_TRAIT_SPEC1(trait,sp,C) \
Jeff Thompsonf7d49942013-08-01 16:47:40 -0700105template<> struct trait< sp > \
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700106 NDNBOOST_TT_AUX_BOOL_C_BASE(C) \
Jeff Thompsonf7d49942013-08-01 16:47:40 -0700107{ \
108public:\
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700109 NDNBOOST_TT_AUX_BOOL_TRAIT_VALUE_DECL(C) \
110 NDNBOOST_MPL_AUX_LAMBDA_SUPPORT_SPEC(1,trait,(sp)) \
Jeff Thompsonf7d49942013-08-01 16:47:40 -0700111}; \
112/**/
113
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700114#define NDNBOOST_TT_AUX_BOOL_TRAIT_SPEC2(trait,sp1,sp2,C) \
Jeff Thompsonf7d49942013-08-01 16:47:40 -0700115template<> struct trait< sp1,sp2 > \
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700116 NDNBOOST_TT_AUX_BOOL_C_BASE(C) \
Jeff Thompsonf7d49942013-08-01 16:47:40 -0700117{ \
118public:\
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700119 NDNBOOST_TT_AUX_BOOL_TRAIT_VALUE_DECL(C) \
120 NDNBOOST_MPL_AUX_LAMBDA_SUPPORT_SPEC(2,trait,(sp1,sp2)) \
Jeff Thompsonf7d49942013-08-01 16:47:40 -0700121}; \
122/**/
123
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700124#define NDNBOOST_TT_AUX_BOOL_TRAIT_IMPL_SPEC1(trait,sp,C) \
Jeff Thompsonf7d49942013-08-01 16:47:40 -0700125template<> struct trait##_impl< sp > \
126{ \
127public:\
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700128 NDNBOOST_STATIC_CONSTANT(bool, value = (C)); \
Jeff Thompsonf7d49942013-08-01 16:47:40 -0700129}; \
130/**/
131
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700132#define NDNBOOST_TT_AUX_BOOL_TRAIT_IMPL_SPEC2(trait,sp1,sp2,C) \
Jeff Thompsonf7d49942013-08-01 16:47:40 -0700133template<> struct trait##_impl< sp1,sp2 > \
134{ \
135public:\
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700136 NDNBOOST_STATIC_CONSTANT(bool, value = (C)); \
Jeff Thompsonf7d49942013-08-01 16:47:40 -0700137}; \
138/**/
139
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700140#define NDNBOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC1_1(param,trait,sp,C) \
Jeff Thompsonf7d49942013-08-01 16:47:40 -0700141template< param > struct trait< sp > \
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700142 NDNBOOST_TT_AUX_BOOL_C_BASE(C) \
Jeff Thompsonf7d49942013-08-01 16:47:40 -0700143{ \
144public:\
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700145 NDNBOOST_TT_AUX_BOOL_TRAIT_VALUE_DECL(C) \
Jeff Thompsonf7d49942013-08-01 16:47:40 -0700146}; \
147/**/
148
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700149#define NDNBOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC1_2(param1,param2,trait,sp,C) \
Jeff Thompsonf7d49942013-08-01 16:47:40 -0700150template< param1, param2 > struct trait< sp > \
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700151 NDNBOOST_TT_AUX_BOOL_C_BASE(C) \
Jeff Thompsonf7d49942013-08-01 16:47:40 -0700152{ \
153public:\
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700154 NDNBOOST_TT_AUX_BOOL_TRAIT_VALUE_DECL(C) \
Jeff Thompsonf7d49942013-08-01 16:47:40 -0700155}; \
156/**/
157
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700158#define NDNBOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC2_1(param,trait,sp1,sp2,C) \
Jeff Thompsonf7d49942013-08-01 16:47:40 -0700159template< param > struct trait< sp1,sp2 > \
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700160 NDNBOOST_TT_AUX_BOOL_C_BASE(C) \
Jeff Thompsonf7d49942013-08-01 16:47:40 -0700161{ \
162public:\
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700163 NDNBOOST_TT_AUX_BOOL_TRAIT_VALUE_DECL(C) \
164 NDNBOOST_MPL_AUX_LAMBDA_SUPPORT_SPEC(2,trait,(sp1,sp2)) \
Jeff Thompsonf7d49942013-08-01 16:47:40 -0700165}; \
166/**/
167
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700168#define NDNBOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC2_2(param1,param2,trait,sp1,sp2,C) \
Jeff Thompsonf7d49942013-08-01 16:47:40 -0700169template< param1, param2 > struct trait< sp1,sp2 > \
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700170 NDNBOOST_TT_AUX_BOOL_C_BASE(C) \
Jeff Thompsonf7d49942013-08-01 16:47:40 -0700171{ \
172public:\
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700173 NDNBOOST_TT_AUX_BOOL_TRAIT_VALUE_DECL(C) \
Jeff Thompsonf7d49942013-08-01 16:47:40 -0700174}; \
175/**/
176
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700177#define NDNBOOST_TT_AUX_BOOL_TRAIT_IMPL_PARTIAL_SPEC2_1(param,trait,sp1,sp2,C) \
Jeff Thompsonf7d49942013-08-01 16:47:40 -0700178template< param > struct trait##_impl< sp1,sp2 > \
179{ \
180public:\
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700181 NDNBOOST_STATIC_CONSTANT(bool, value = (C)); \
Jeff Thompsonf7d49942013-08-01 16:47:40 -0700182}; \
183/**/
184
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700185#ifndef NDNBOOST_NO_CV_SPECIALIZATIONS
186# define NDNBOOST_TT_AUX_BOOL_TRAIT_CV_SPEC1(trait,sp,value) \
187 NDNBOOST_TT_AUX_BOOL_TRAIT_SPEC1(trait,sp,value) \
188 NDNBOOST_TT_AUX_BOOL_TRAIT_SPEC1(trait,sp const,value) \
189 NDNBOOST_TT_AUX_BOOL_TRAIT_SPEC1(trait,sp volatile,value) \
190 NDNBOOST_TT_AUX_BOOL_TRAIT_SPEC1(trait,sp const volatile,value) \
Jeff Thompsonf7d49942013-08-01 16:47:40 -0700191 /**/
192#else
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700193# define NDNBOOST_TT_AUX_BOOL_TRAIT_CV_SPEC1(trait,sp,value) \
194 NDNBOOST_TT_AUX_BOOL_TRAIT_SPEC1(trait,sp,value) \
Jeff Thompsonf7d49942013-08-01 16:47:40 -0700195 /**/
196#endif