2 // NO INCLUDE GUARDS, THE HEADER IS INTENDED FOR MULTIPLE INCLUSION
4 // Copyright Aleksey Gurtovoy 2002-2004
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)
11 // $Date: 2011-04-25 08:26:48 -0400 (Mon, 25 Apr 2011) $
14 #include <boost/type_traits/detail/template_arity_spec.hpp>
15 #include <boost/type_traits/integral_constant.hpp>
16 #include <boost/mpl/bool.hpp>
17 #include <boost/mpl/aux_/lambda_support.hpp>
18 #include <boost/config.hpp>
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....
25 #ifdef BOOST_TT_AUX_BOOL_TRAIT_VALUE_DECL
26 #undef BOOST_TT_AUX_BOOL_TRAIT_VALUE_DECL
27 #undef BOOST_TT_AUX_BOOL_C_BASE
28 #undef BOOST_TT_AUX_BOOL_TRAIT_DEF1
29 #undef BOOST_TT_AUX_BOOL_TRAIT_DEF2
30 #undef BOOST_TT_AUX_BOOL_TRAIT_SPEC1
31 #undef BOOST_TT_AUX_BOOL_TRAIT_SPEC2
32 #undef BOOST_TT_AUX_BOOL_TRAIT_IMPL_SPEC1
33 #undef BOOST_TT_AUX_BOOL_TRAIT_IMPL_SPEC2
34 #undef BOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC1_1
35 #undef BOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC1_2
36 #undef BOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC2_1
37 #undef BOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC2_2
38 #undef BOOST_TT_AUX_BOOL_TRAIT_IMPL_PARTIAL_SPEC2_1
39 #undef BOOST_TT_AUX_BOOL_TRAIT_CV_SPEC1
42 #if defined(__SUNPRO_CC) && (__SUNPRO_CC < 0x570)
43 # define BOOST_TT_AUX_BOOL_TRAIT_VALUE_DECL(C) \
44 typedef ::boost::integral_constant<bool,C> type; \
45 enum { value = type::value }; \
47 # define BOOST_TT_AUX_BOOL_C_BASE(C)
49 #elif defined(BOOST_MSVC) && BOOST_MSVC < 1300
51 # define BOOST_TT_AUX_BOOL_TRAIT_VALUE_DECL(C) \
52 typedef ::boost::integral_constant<bool,C> base_; \
58 #ifndef BOOST_TT_AUX_BOOL_TRAIT_VALUE_DECL
59 # define BOOST_TT_AUX_BOOL_TRAIT_VALUE_DECL(C) /**/
62 #ifndef BOOST_TT_AUX_BOOL_C_BASE
63 # define BOOST_TT_AUX_BOOL_C_BASE(C) : public ::boost::integral_constant<bool,C>
67 #define BOOST_TT_AUX_BOOL_TRAIT_DEF1(trait,T,C) \
68 template< typename T > struct trait \
69 BOOST_TT_AUX_BOOL_C_BASE(C) \
72 BOOST_TT_AUX_BOOL_TRAIT_VALUE_DECL(C) \
73 BOOST_MPL_AUX_LAMBDA_SUPPORT(1,trait,(T)) \
76 BOOST_TT_AUX_TEMPLATE_ARITY_SPEC(1,trait) \
80 #define BOOST_TT_AUX_BOOL_TRAIT_DEF2(trait,T1,T2,C) \
81 template< typename T1, typename T2 > struct trait \
82 BOOST_TT_AUX_BOOL_C_BASE(C) \
85 BOOST_TT_AUX_BOOL_TRAIT_VALUE_DECL(C) \
86 BOOST_MPL_AUX_LAMBDA_SUPPORT(2,trait,(T1,T2)) \
89 BOOST_TT_AUX_TEMPLATE_ARITY_SPEC(2,trait) \
92 #define BOOST_TT_AUX_BOOL_TRAIT_SPEC1(trait,sp,C) \
93 template<> struct trait< sp > \
94 BOOST_TT_AUX_BOOL_C_BASE(C) \
97 BOOST_TT_AUX_BOOL_TRAIT_VALUE_DECL(C) \
98 BOOST_MPL_AUX_LAMBDA_SUPPORT_SPEC(1,trait,(sp)) \
102 #define BOOST_TT_AUX_BOOL_TRAIT_SPEC2(trait,sp1,sp2,C) \
103 template<> struct trait< sp1,sp2 > \
104 BOOST_TT_AUX_BOOL_C_BASE(C) \
107 BOOST_TT_AUX_BOOL_TRAIT_VALUE_DECL(C) \
108 BOOST_MPL_AUX_LAMBDA_SUPPORT_SPEC(2,trait,(sp1,sp2)) \
112 #define BOOST_TT_AUX_BOOL_TRAIT_IMPL_SPEC1(trait,sp,C) \
113 template<> struct trait##_impl< sp > \
116 BOOST_STATIC_CONSTANT(bool, value = (C)); \
120 #define BOOST_TT_AUX_BOOL_TRAIT_IMPL_SPEC2(trait,sp1,sp2,C) \
121 template<> struct trait##_impl< sp1,sp2 > \
124 BOOST_STATIC_CONSTANT(bool, value = (C)); \
128 #define BOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC1_1(param,trait,sp,C) \
129 template< param > struct trait< sp > \
130 BOOST_TT_AUX_BOOL_C_BASE(C) \
133 BOOST_TT_AUX_BOOL_TRAIT_VALUE_DECL(C) \
137 #define BOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC1_2(param1,param2,trait,sp,C) \
138 template< param1, param2 > struct trait< sp > \
139 BOOST_TT_AUX_BOOL_C_BASE(C) \
142 BOOST_TT_AUX_BOOL_TRAIT_VALUE_DECL(C) \
146 #define BOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC2_1(param,trait,sp1,sp2,C) \
147 template< param > struct trait< sp1,sp2 > \
148 BOOST_TT_AUX_BOOL_C_BASE(C) \
151 BOOST_TT_AUX_BOOL_TRAIT_VALUE_DECL(C) \
152 BOOST_MPL_AUX_LAMBDA_SUPPORT_SPEC(2,trait,(sp1,sp2)) \
156 #define BOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC2_2(param1,param2,trait,sp1,sp2,C) \
157 template< param1, param2 > struct trait< sp1,sp2 > \
158 BOOST_TT_AUX_BOOL_C_BASE(C) \
161 BOOST_TT_AUX_BOOL_TRAIT_VALUE_DECL(C) \
165 #define BOOST_TT_AUX_BOOL_TRAIT_IMPL_PARTIAL_SPEC2_1(param,trait,sp1,sp2,C) \
166 template< param > struct trait##_impl< sp1,sp2 > \
169 BOOST_STATIC_CONSTANT(bool, value = (C)); \
173 #ifndef BOOST_NO_CV_SPECIALIZATIONS
174 # define BOOST_TT_AUX_BOOL_TRAIT_CV_SPEC1(trait,sp,value) \
175 BOOST_TT_AUX_BOOL_TRAIT_SPEC1(trait,sp,value) \
176 BOOST_TT_AUX_BOOL_TRAIT_SPEC1(trait,sp const,value) \
177 BOOST_TT_AUX_BOOL_TRAIT_SPEC1(trait,sp volatile,value) \
178 BOOST_TT_AUX_BOOL_TRAIT_SPEC1(trait,sp const volatile,value) \
181 # define BOOST_TT_AUX_BOOL_TRAIT_CV_SPEC1(trait,sp,value) \
182 BOOST_TT_AUX_BOOL_TRAIT_SPEC1(trait,sp,value) \