1 // Copyright (C) 2004 Peder Holt
2 // Use, modification and distribution is subject to the Boost Software
3 // License, Version 1.0. (http://www.boost.org/LICENSE_1_0.txt)
5 #ifndef BOOST_TYPE_TRAITS_MSVC_REMOVE_CV_HOLT_2004_0901
6 #define BOOST_TYPE_TRAITS_MSVC_REMOVE_CV_HOLT_2004_0901
8 #include <boost/type_traits/msvc/typeof.hpp>
9 #include <boost/type_traits/is_volatile.hpp>
10 #include <boost/type_traits/is_const.hpp>
11 #include <boost/type_traits/is_pointer.hpp>
12 #include <boost/type_traits/is_array.hpp>
16 template<bool IsPointer,bool IsArray,bool IsConst,bool IsVolatile>
17 struct remove_cv_impl_typeof {
18 template<typename T,typename ID>
23 struct transform_type {
28 struct remove_cv_impl_typeof<false,false,false,true> {
29 template<typename T,typename ID>
32 static msvc_register_type<U,ID> test(U volatile&(*)());
33 static msvc_register_type<T,ID> test(...);
34 BOOST_STATIC_CONSTANT(unsigned,register_test=sizeof(test( (T(*)())(NULL) ) ));
35 typedef typename msvc_extract_type<ID>::id2type::type type;
38 struct transform_type {
43 struct remove_cv_impl_typeof<false,false,true,false> {
44 template<typename T,typename ID>
47 static msvc_register_type<U,ID> test(U const&(*)());
48 static msvc_register_type<T,ID> test(...);
49 BOOST_STATIC_CONSTANT(unsigned,register_test=sizeof(test( (T(*)())(NULL) ) ));
50 typedef typename msvc_extract_type<ID>::id2type::type type;
53 struct transform_type {
58 struct remove_cv_impl_typeof<false,false,true,true> {
59 template<typename T,typename ID>
62 static msvc_register_type<U,ID> test(U const volatile&(*)());
63 static msvc_register_type<T,ID> test(...);
64 BOOST_STATIC_CONSTANT(unsigned,register_test=sizeof(test( (T(*)())(NULL) ) ));
65 typedef typename msvc_extract_type<ID>::id2type::type type;
68 struct transform_type {
72 template<> //Volatile Pointer
73 struct remove_cv_impl_typeof<true,false,false,true> {
74 template<typename T,typename ID>
77 static msvc_register_type<U,ID> test(void(*)(U volatile[]));
78 static msvc_register_type<T,ID> test(...);
79 BOOST_STATIC_CONSTANT(unsigned,register_test=sizeof(test( (void(*)(T))(NULL) ) ));
80 typedef typename msvc_extract_type<ID>::id2type::type type;
83 struct transform_type {
87 template<> //Const Pointer
88 struct remove_cv_impl_typeof<true,false,true,false> {
89 template<typename T,typename ID>
92 static msvc_register_type<U,ID> test(void(*)(U const[]));
93 static msvc_register_type<T,ID> test(...);
94 BOOST_STATIC_CONSTANT(unsigned,register_test=sizeof(test( (void(*)(T))(NULL) ) ));
95 typedef typename msvc_extract_type<ID>::id2type::type type;
98 struct transform_type {
102 template<> //CV Pointer
103 struct remove_cv_impl_typeof<true,false,true,true> {
104 template<typename T,typename ID>
107 static msvc_register_type<U,ID> test(void(*)(U const volatile[]));
108 static msvc_register_type<T,ID> test(...);
109 BOOST_STATIC_CONSTANT(unsigned,register_test=sizeof(test( (void(*)(T))(NULL) ) ));
110 typedef typename msvc_extract_type<ID>::id2type::type type;
113 struct transform_type {
117 template<> //Volatile Array
118 struct remove_cv_impl_typeof<false,true,false,true> {
119 template<typename T,typename ID>
121 BOOST_STATIC_CONSTANT(unsigned,value=(sizeof(T)/sizeof((*((T*)NULL))[0])));
124 static msvc_register_type<U[value],ID> test(void(*)(U volatile[]));
125 static msvc_register_type<T,ID> test(...);
126 BOOST_STATIC_CONSTANT(unsigned,register_test=sizeof(test( (void(*)(T))(NULL) ) ));
127 typedef typename msvc_extract_type<ID>::id2type::type type;
130 struct transform_type {
134 template<> //Const Array
135 struct remove_cv_impl_typeof<false,true,true,false> {
136 template<typename T,typename ID>
138 BOOST_STATIC_CONSTANT(unsigned,value=(sizeof(T)/sizeof((*((T*)NULL))[0])));
141 static msvc_register_type<U[value],ID> test(void(*)(U const[]));
142 static msvc_register_type<T,ID> test(...);
143 BOOST_STATIC_CONSTANT(unsigned,register_test=sizeof(test( (void(*)(T))(NULL) ) ));
144 typedef typename msvc_extract_type<ID>::id2type::type type;
147 struct transform_type {
152 template<> //CV Array
153 struct remove_cv_impl_typeof<false,true,true,true> {
154 template<typename T,typename ID>
156 BOOST_STATIC_CONSTANT(unsigned,value=(sizeof(T)/sizeof((*((T*)NULL))[0])));
159 static msvc_register_type<U[value],ID> test(void(*)(U const volatile[]));
160 static msvc_register_type<T,ID> test(...);
161 BOOST_STATIC_CONSTANT(unsigned,register_test=sizeof(test( (void(*)(T))(NULL) ) ));
162 typedef typename msvc_extract_type<ID>::id2type::type type;
165 struct transform_type {
174 typedef boost::detail::remove_cv_impl_typeof<
175 boost::is_pointer<T>::value,
176 boost::is_array<T>::value,
177 boost::is_const<T>::value,
178 boost::is_volatile<T>::value
181 remove_cv_type::template inner<
182 typename remove_cv_type::template transform_type<T>::type,
186 BOOST_MPL_AUX_LAMBDA_SUPPORT(1,remove_cv,T)
190 #endif //BOOST_TYPE_TRAITS_MSVC_REMOVE_CV_HOLT_2004_0901