Brian Silverman | 2987761 | 2018-08-05 00:42:41 -0700 | [diff] [blame^] | 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/is_function.hpp> |
| 8 | # include <boost/type_traits/is_reference.hpp> |
| 9 | # include <boost/type_traits/is_pointer.hpp> |
| 10 | # include <boost/type_traits/is_class.hpp> |
| 11 | # include <boost/type_traits/is_const.hpp> |
| 12 | # include <boost/type_traits/is_volatile.hpp> |
| 13 | # include <boost/type_traits/is_member_function_pointer.hpp> |
| 14 | # include <boost/type_traits/is_member_pointer.hpp> |
| 15 | # include <boost/type_traits/remove_cv.hpp> |
| 16 | # include <boost/type_traits/remove_reference.hpp> |
| 17 | # include <boost/type_traits/remove_pointer.hpp> |
| 18 | |
| 19 | # include <boost/detail/workaround.hpp> |
| 20 | |
| 21 | # include <boost/mpl/eval_if.hpp> |
| 22 | # include <boost/mpl/if.hpp> |
| 23 | # include <boost/mpl/bool.hpp> |
| 24 | # include <boost/mpl/and.hpp> |
| 25 | # include <boost/mpl/not.hpp> |
| 26 | # include <boost/mpl/aux_/lambda_support.hpp> |
| 27 | |
| 28 | |
| 29 | namespace boost { namespace detail { |
| 30 | |
| 31 | namespace indirect_traits { |
| 32 | |
| 33 | template <class T> |
| 34 | struct is_reference_to_const : mpl::false_ |
| 35 | { |
| 36 | }; |
| 37 | |
| 38 | template <class T> |
| 39 | struct is_reference_to_const<T const&> : mpl::true_ |
| 40 | { |
| 41 | }; |
| 42 | |
| 43 | # if defined(BOOST_MSVC) && _MSC_FULL_VER <= 13102140 // vc7.01 alpha workaround |
| 44 | template<class T> |
| 45 | struct is_reference_to_const<T const volatile&> : mpl::true_ |
| 46 | { |
| 47 | }; |
| 48 | # endif |
| 49 | |
| 50 | template <class T> |
| 51 | struct is_reference_to_function : mpl::false_ |
| 52 | { |
| 53 | }; |
| 54 | |
| 55 | template <class T> |
| 56 | struct is_reference_to_function<T&> : is_function<T> |
| 57 | { |
| 58 | }; |
| 59 | |
| 60 | template <class T> |
| 61 | struct is_pointer_to_function : mpl::false_ |
| 62 | { |
| 63 | }; |
| 64 | |
| 65 | // There's no such thing as a pointer-to-cv-function, so we don't need |
| 66 | // specializations for those |
| 67 | template <class T> |
| 68 | struct is_pointer_to_function<T*> : is_function<T> |
| 69 | { |
| 70 | }; |
| 71 | |
| 72 | template <class T> |
| 73 | struct is_reference_to_member_function_pointer_impl : mpl::false_ |
| 74 | { |
| 75 | }; |
| 76 | |
| 77 | template <class T> |
| 78 | struct is_reference_to_member_function_pointer_impl<T&> |
| 79 | : is_member_function_pointer<typename remove_cv<T>::type> |
| 80 | { |
| 81 | }; |
| 82 | |
| 83 | |
| 84 | template <class T> |
| 85 | struct is_reference_to_member_function_pointer |
| 86 | : is_reference_to_member_function_pointer_impl<T> |
| 87 | { |
| 88 | BOOST_MPL_AUX_LAMBDA_SUPPORT(1,is_reference_to_member_function_pointer,(T)) |
| 89 | }; |
| 90 | |
| 91 | template <class T> |
| 92 | struct is_reference_to_function_pointer_aux |
| 93 | : mpl::and_< |
| 94 | is_reference<T> |
| 95 | , is_pointer_to_function< |
| 96 | typename remove_cv< |
| 97 | typename remove_reference<T>::type |
| 98 | >::type |
| 99 | > |
| 100 | > |
| 101 | { |
| 102 | // There's no such thing as a pointer-to-cv-function, so we don't need specializations for those |
| 103 | }; |
| 104 | |
| 105 | template <class T> |
| 106 | struct is_reference_to_function_pointer |
| 107 | : mpl::if_< |
| 108 | is_reference_to_function<T> |
| 109 | , mpl::false_ |
| 110 | , is_reference_to_function_pointer_aux<T> |
| 111 | >::type |
| 112 | { |
| 113 | }; |
| 114 | |
| 115 | template <class T> |
| 116 | struct is_reference_to_non_const |
| 117 | : mpl::and_< |
| 118 | is_reference<T> |
| 119 | , mpl::not_< |
| 120 | is_reference_to_const<T> |
| 121 | > |
| 122 | > |
| 123 | { |
| 124 | }; |
| 125 | |
| 126 | template <class T> |
| 127 | struct is_reference_to_volatile : mpl::false_ |
| 128 | { |
| 129 | }; |
| 130 | |
| 131 | template <class T> |
| 132 | struct is_reference_to_volatile<T volatile&> : mpl::true_ |
| 133 | { |
| 134 | }; |
| 135 | |
| 136 | # if defined(BOOST_MSVC) && _MSC_FULL_VER <= 13102140 // vc7.01 alpha workaround |
| 137 | template <class T> |
| 138 | struct is_reference_to_volatile<T const volatile&> : mpl::true_ |
| 139 | { |
| 140 | }; |
| 141 | # endif |
| 142 | |
| 143 | |
| 144 | template <class T> |
| 145 | struct is_reference_to_pointer : mpl::false_ |
| 146 | { |
| 147 | }; |
| 148 | |
| 149 | template <class T> |
| 150 | struct is_reference_to_pointer<T*&> : mpl::true_ |
| 151 | { |
| 152 | }; |
| 153 | |
| 154 | template <class T> |
| 155 | struct is_reference_to_pointer<T* const&> : mpl::true_ |
| 156 | { |
| 157 | }; |
| 158 | |
| 159 | template <class T> |
| 160 | struct is_reference_to_pointer<T* volatile&> : mpl::true_ |
| 161 | { |
| 162 | }; |
| 163 | |
| 164 | template <class T> |
| 165 | struct is_reference_to_pointer<T* const volatile&> : mpl::true_ |
| 166 | { |
| 167 | }; |
| 168 | |
| 169 | template <class T> |
| 170 | struct is_reference_to_class |
| 171 | : mpl::and_< |
| 172 | is_reference<T> |
| 173 | , is_class< |
| 174 | typename remove_cv< |
| 175 | typename remove_reference<T>::type |
| 176 | >::type |
| 177 | > |
| 178 | > |
| 179 | { |
| 180 | BOOST_MPL_AUX_LAMBDA_SUPPORT(1,is_reference_to_class,(T)) |
| 181 | }; |
| 182 | |
| 183 | template <class T> |
| 184 | struct is_pointer_to_class |
| 185 | : mpl::and_< |
| 186 | is_pointer<T> |
| 187 | , is_class< |
| 188 | typename remove_cv< |
| 189 | typename remove_pointer<T>::type |
| 190 | >::type |
| 191 | > |
| 192 | > |
| 193 | { |
| 194 | BOOST_MPL_AUX_LAMBDA_SUPPORT(1,is_pointer_to_class,(T)) |
| 195 | }; |
| 196 | |
| 197 | |
| 198 | } |
| 199 | |
| 200 | using namespace indirect_traits; |
| 201 | |
| 202 | }} // namespace boost::python::detail |
| 203 | |
| 204 | #endif // INDIRECT_TRAITS_DWA2002131_HPP |