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_VOLATILE_HOLT_2004_0828
6 #define BOOST_TYPE_TRAITS_MSVC_REMOVE_VOLATILE_HOLT_2004_0828
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_volatile_impl_typeof {
18 template<typename T,typename ID>
23 struct transform_type {
28 struct remove_volatile_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_volatile_impl_typeof<false,false,true,true> {
44 template<typename T,typename ID>
47 static msvc_register_type<U const,ID> test(U const volatile&(*)());
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 {
57 template<> //Volatile Pointer
58 struct remove_volatile_impl_typeof<true,false,false,true> {
59 template<typename T,typename ID>
62 static msvc_register_type<U,ID> test(void(*)(U volatile[]));
63 static msvc_register_type<T,ID> test(...);
64 BOOST_STATIC_CONSTANT(unsigned,register_test=sizeof(test( (void(*)(T))(NULL) ) ));
65 typedef typename msvc_extract_type<ID>::id2type::type type;
68 struct transform_type {
72 template<> //CV Pointer
73 struct remove_volatile_impl_typeof<true,false,true,true> {
74 template<typename T,typename ID>
77 static msvc_register_type<U const,ID> test(void(*)(U const 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<> //Volatile Array
88 struct remove_volatile_impl_typeof<false,true,false,true> {
89 template<typename T,typename ID>
91 BOOST_STATIC_CONSTANT(unsigned,value=(sizeof(T)/sizeof((*((T*)NULL))[0])));
94 static msvc_register_type<U[value],ID> test(void(*)(U volatile[]));
95 static msvc_register_type<T,ID> test(...);
96 BOOST_STATIC_CONSTANT(unsigned,register_test=sizeof(test( (void(*)(T))(NULL) ) ));
97 typedef typename msvc_extract_type<ID>::id2type::type type;
100 struct transform_type {
105 template<> //CV Array
106 struct remove_volatile_impl_typeof<false,true,true,true> {
107 template<typename T,typename ID>
109 BOOST_STATIC_CONSTANT(unsigned,value=(sizeof(T)/sizeof((*((T*)NULL))[0])));
112 static msvc_register_type<U const[value],ID> test(void(*)(U const volatile[]));
113 static msvc_register_type<T,ID> test(...);
114 BOOST_STATIC_CONSTANT(unsigned,register_test=sizeof(test( (void(*)(T))(NULL) ) ));
115 typedef typename msvc_extract_type<ID>::id2type::type type;
118 struct transform_type {
126 struct remove_volatile {
127 typedef boost::detail::remove_volatile_impl_typeof<
128 boost::is_pointer<T>::value,
129 boost::is_array<T>::value,
130 boost::is_const<T>::value,
131 boost::is_volatile<T>::value
132 > remove_volatile_type;
134 remove_volatile_type::template inner<
135 typename remove_volatile_type::template transform_type<T>::type,
139 BOOST_MPL_AUX_LAMBDA_SUPPORT(1,remove_volatile,T)
143 #endif //BOOST_TYPE_TRAITS_MSVC_REMOVE_VOLATILE_HOLT_2004_0828