1 
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 
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>
19 
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 //
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
40 #endif
41 
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 }; \
46     /**/
47 #   define BOOST_TT_AUX_BOOL_C_BASE(C)
48 
49 #elif defined(BOOST_MSVC) && BOOST_MSVC < 1300
50 
51 #   define BOOST_TT_AUX_BOOL_TRAIT_VALUE_DECL(C) \
52     typedef ::boost::integral_constant<bool,C> base_; \
53     using base_::value; \
54     /**/
55 
56 #endif
57 
58 #ifndef BOOST_TT_AUX_BOOL_TRAIT_VALUE_DECL
59 #   define BOOST_TT_AUX_BOOL_TRAIT_VALUE_DECL(C) /**/
60 #endif
61 
62 #ifndef BOOST_TT_AUX_BOOL_C_BASE
63 #   define BOOST_TT_AUX_BOOL_C_BASE(C) : public ::boost::integral_constant<bool,C>
64 #endif
65 
66 
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) \
70 { \
71 public:\
72     BOOST_TT_AUX_BOOL_TRAIT_VALUE_DECL(C) \
73     BOOST_MPL_AUX_LAMBDA_SUPPORT(1,trait,(T)) \
74 }; \
75 \
76 BOOST_TT_AUX_TEMPLATE_ARITY_SPEC(1,trait) \
77 /**/
78 
79 
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) \
83 { \
84 public:\
85     BOOST_TT_AUX_BOOL_TRAIT_VALUE_DECL(C) \
86     BOOST_MPL_AUX_LAMBDA_SUPPORT(2,trait,(T1,T2)) \
87 }; \
88 \
89 BOOST_TT_AUX_TEMPLATE_ARITY_SPEC(2,trait) \
90 /**/
91 
92 #define BOOST_TT_AUX_BOOL_TRAIT_DEF3(trait,T1,T2,T3,C) \
93 template< typename T1, typename T2, typename T3 > struct trait \
94     BOOST_TT_AUX_BOOL_C_BASE(C) \
95 { \
96 public:\
97     BOOST_TT_AUX_BOOL_TRAIT_VALUE_DECL(C) \
98     BOOST_MPL_AUX_LAMBDA_SUPPORT(3,trait,(T1,T2,T3)) \
99 }; \
100 \
101 BOOST_TT_AUX_TEMPLATE_ARITY_SPEC(3,trait) \
102 /**/
103 
104 #define BOOST_TT_AUX_BOOL_TRAIT_SPEC1(trait,sp,C) \
105 template<> struct trait< sp > \
106     BOOST_TT_AUX_BOOL_C_BASE(C) \
107 { \
108 public:\
109     BOOST_TT_AUX_BOOL_TRAIT_VALUE_DECL(C) \
110     BOOST_MPL_AUX_LAMBDA_SUPPORT_SPEC(1,trait,(sp)) \
111 }; \
112 /**/
113 
114 #define BOOST_TT_AUX_BOOL_TRAIT_SPEC2(trait,sp1,sp2,C) \
115 template<> struct trait< sp1,sp2 > \
116     BOOST_TT_AUX_BOOL_C_BASE(C) \
117 { \
118 public:\
119     BOOST_TT_AUX_BOOL_TRAIT_VALUE_DECL(C) \
120     BOOST_MPL_AUX_LAMBDA_SUPPORT_SPEC(2,trait,(sp1,sp2)) \
121 }; \
122 /**/
123 
124 #define BOOST_TT_AUX_BOOL_TRAIT_IMPL_SPEC1(trait,sp,C) \
125 template<> struct trait##_impl< sp > \
126 { \
127 public:\
128     BOOST_STATIC_CONSTANT(bool, value = (C)); \
129 }; \
130 /**/
131 
132 #define BOOST_TT_AUX_BOOL_TRAIT_IMPL_SPEC2(trait,sp1,sp2,C) \
133 template<> struct trait##_impl< sp1,sp2 > \
134 { \
135 public:\
136     BOOST_STATIC_CONSTANT(bool, value = (C)); \
137 }; \
138 /**/
139 
140 #define BOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC1_1(param,trait,sp,C) \
141 template< param > struct trait< sp > \
142     BOOST_TT_AUX_BOOL_C_BASE(C) \
143 { \
144 public:\
145     BOOST_TT_AUX_BOOL_TRAIT_VALUE_DECL(C) \
146 }; \
147 /**/
148 
149 #define BOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC1_2(param1,param2,trait,sp,C) \
150 template< param1, param2 > struct trait< sp > \
151     BOOST_TT_AUX_BOOL_C_BASE(C) \
152 { \
153 public:\
154     BOOST_TT_AUX_BOOL_TRAIT_VALUE_DECL(C) \
155 }; \
156 /**/
157 
158 #define BOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC2_1(param,trait,sp1,sp2,C) \
159 template< param > struct trait< sp1,sp2 > \
160     BOOST_TT_AUX_BOOL_C_BASE(C) \
161 { \
162 public:\
163     BOOST_TT_AUX_BOOL_TRAIT_VALUE_DECL(C) \
164     BOOST_MPL_AUX_LAMBDA_SUPPORT_SPEC(2,trait,(sp1,sp2)) \
165 }; \
166 /**/
167 
168 #define BOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC2_2(param1,param2,trait,sp1,sp2,C) \
169 template< param1, param2 > struct trait< sp1,sp2 > \
170     BOOST_TT_AUX_BOOL_C_BASE(C) \
171 { \
172 public:\
173     BOOST_TT_AUX_BOOL_TRAIT_VALUE_DECL(C) \
174 }; \
175 /**/
176 
177 #define BOOST_TT_AUX_BOOL_TRAIT_IMPL_PARTIAL_SPEC2_1(param,trait,sp1,sp2,C) \
178 template< param > struct trait##_impl< sp1,sp2 > \
179 { \
180 public:\
181     BOOST_STATIC_CONSTANT(bool, value = (C)); \
182 }; \
183 /**/
184 
185 #ifndef BOOST_NO_CV_SPECIALIZATIONS
186 #   define BOOST_TT_AUX_BOOL_TRAIT_CV_SPEC1(trait,sp,value) \
187     BOOST_TT_AUX_BOOL_TRAIT_SPEC1(trait,sp,value) \
188     BOOST_TT_AUX_BOOL_TRAIT_SPEC1(trait,sp const,value) \
189     BOOST_TT_AUX_BOOL_TRAIT_SPEC1(trait,sp volatile,value) \
190     BOOST_TT_AUX_BOOL_TRAIT_SPEC1(trait,sp const volatile,value) \
191     /**/
192 #else
193 #   define BOOST_TT_AUX_BOOL_TRAIT_CV_SPEC1(trait,sp,value) \
194     BOOST_TT_AUX_BOOL_TRAIT_SPEC1(trait,sp,value) \
195     /**/
196 #endif
197