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