1 // Copyright David Abrahams 2002. 2 // Distributed under the Boost Software License, Version 1.0. (See 3 // accompanying file LICENSE_1_0.txt or copy at 4 // http://www.boost.org/LICENSE_1_0.txt) 5 #ifndef INDIRECT_TRAITS_DWA2002131_HPP 6 # define INDIRECT_TRAITS_DWA2002131_HPP 7 # include <boost/type_traits/integral_constant.hpp> 8 # include <boost/type_traits/is_function.hpp> 9 # include <boost/type_traits/is_reference.hpp> 10 # include <boost/type_traits/is_pointer.hpp> 11 # include <boost/type_traits/is_class.hpp> 12 # include <boost/type_traits/is_const.hpp> 13 # include <boost/type_traits/is_volatile.hpp> 14 # include <boost/type_traits/is_member_function_pointer.hpp> 15 # include <boost/type_traits/is_member_pointer.hpp> 16 # include <boost/type_traits/remove_cv.hpp> 17 # include <boost/type_traits/remove_reference.hpp> 18 # include <boost/type_traits/remove_pointer.hpp> 19 20 # include <boost/detail/workaround.hpp> 21 # include <boost/detail/select_type.hpp> 22 23 24 namespace boost { namespace detail { 25 26 namespace indirect_traits { 27 28 template <class T> 29 struct is_reference_to_const : boost::false_type 30 { 31 }; 32 33 template <class T> 34 struct is_reference_to_const<T const&> : boost::true_type 35 { 36 }; 37 38 # if defined(BOOST_MSVC) && _MSC_FULL_VER <= 13102140 // vc7.01 alpha workaround 39 template<class T> 40 struct is_reference_to_const<T const volatile&> : boost::true_type 41 { 42 }; 43 # endif 44 45 template <class T> 46 struct is_reference_to_function : boost::false_type 47 { 48 }; 49 50 template <class T> 51 struct is_reference_to_function<T&> : is_function<T> 52 { 53 }; 54 55 template <class T> 56 struct is_pointer_to_function : boost::false_type 57 { 58 }; 59 60 // There's no such thing as a pointer-to-cv-function, so we don't need 61 // specializations for those 62 template <class T> 63 struct is_pointer_to_function<T*> : is_function<T> 64 { 65 }; 66 67 template <class T> 68 struct is_reference_to_member_function_pointer_impl : boost::false_type 69 { 70 }; 71 72 template <class T> 73 struct is_reference_to_member_function_pointer_impl<T&> 74 : is_member_function_pointer<typename remove_cv<T>::type> 75 { 76 }; 77 78 79 template <class T> 80 struct is_reference_to_member_function_pointer 81 : is_reference_to_member_function_pointer_impl<T> 82 { 83 }; 84 85 template <class T> 86 struct is_reference_to_function_pointer_aux 87 : boost::integral_constant<bool, 88 is_reference<T>::value && 89 is_pointer_to_function< 90 typename remove_cv< 91 typename remove_reference<T>::type 92 >::type 93 >::value 94 > 95 { 96 // There's no such thing as a pointer-to-cv-function, so we don't need specializations for those 97 }; 98 99 template <class T> 100 struct is_reference_to_function_pointer 101 : boost::detail::if_true< 102 is_reference_to_function<T>::value 103 >::template then< 104 boost::false_type 105 , is_reference_to_function_pointer_aux<T> 106 >::type 107 { 108 }; 109 110 template <class T> 111 struct is_reference_to_non_const 112 : boost::integral_constant<bool, 113 is_reference<T>::value && 114 !is_reference_to_const<T>::value 115 > 116 { 117 }; 118 119 template <class T> 120 struct is_reference_to_volatile : boost::false_type 121 { 122 }; 123 124 template <class T> 125 struct is_reference_to_volatile<T volatile&> : boost::true_type 126 { 127 }; 128 129 # if defined(BOOST_MSVC) && _MSC_FULL_VER <= 13102140 // vc7.01 alpha workaround 130 template <class T> 131 struct is_reference_to_volatile<T const volatile&> : boost::true_type 132 { 133 }; 134 # endif 135 136 137 template <class T> 138 struct is_reference_to_pointer : boost::false_type 139 { 140 }; 141 142 template <class T> 143 struct is_reference_to_pointer<T*&> : boost::true_type 144 { 145 }; 146 147 template <class T> 148 struct is_reference_to_pointer<T* const&> : boost::true_type 149 { 150 }; 151 152 template <class T> 153 struct is_reference_to_pointer<T* volatile&> : boost::true_type 154 { 155 }; 156 157 template <class T> 158 struct is_reference_to_pointer<T* const volatile&> : boost::true_type 159 { 160 }; 161 162 template <class T> 163 struct is_reference_to_class 164 : boost::integral_constant<bool, 165 is_reference<T>::value && 166 is_class< 167 typename remove_cv< 168 typename remove_reference<T>::type 169 >::type 170 >::value 171 > 172 { 173 }; 174 175 template <class T> 176 struct is_pointer_to_class 177 : boost::integral_constant<bool, 178 is_pointer<T>::value && 179 is_class< 180 typename remove_cv< 181 typename remove_pointer<T>::type 182 >::type 183 >::value 184 > 185 { 186 }; 187 188 189 } 190 191 using namespace indirect_traits; 192 193 }} // namespace boost::python::detail 194 195 #endif // INDIRECT_TRAITS_DWA2002131_HPP 196