[857] | 1 |
|
---|
| 2 | // (C) Copyright Dave Abrahams, Steve Cleary, Beman Dawes,
|
---|
| 3 | // Howard Hinnant and John Maddock 2000.
|
---|
| 4 | // (C) Copyright Mat Marcus, Jesse Jones and Adobe Systems Inc 2001
|
---|
| 5 |
|
---|
| 6 | // Use, modification and distribution are subject to the Boost Software License,
|
---|
| 7 | // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
---|
| 8 | // http://www.boost.org/LICENSE_1_0.txt).
|
---|
| 9 | //
|
---|
| 10 | // See http://www.boost.org/libs/type_traits for most recent version including documentation.
|
---|
| 11 |
|
---|
| 12 | // Fixed is_pointer, is_reference, is_const, is_volatile, is_same,
|
---|
| 13 | // is_member_pointer based on the Simulated Partial Specialization work
|
---|
| 14 | // of Mat Marcus and Jesse Jones. See http://opensource.adobe.com or
|
---|
| 15 | // http://groups.yahoo.com/group/boost/message/5441
|
---|
| 16 | // Some workarounds in here use ideas suggested from "Generic<Programming>:
|
---|
| 17 | // Mappings between Types and Values"
|
---|
| 18 | // by Andrei Alexandrescu (see http://www.cuj.com/experts/1810/alexandr.html).
|
---|
| 19 |
|
---|
| 20 |
|
---|
| 21 | #ifndef BOOST_TT_IS_POINTER_HPP_INCLUDED
|
---|
| 22 | #define BOOST_TT_IS_POINTER_HPP_INCLUDED
|
---|
| 23 |
|
---|
| 24 | #include "boost/type_traits/is_member_pointer.hpp"
|
---|
| 25 | #include "boost/type_traits/detail/ice_and.hpp"
|
---|
| 26 | #include "boost/type_traits/detail/ice_not.hpp"
|
---|
| 27 | #include "boost/type_traits/config.hpp"
|
---|
| 28 |
|
---|
| 29 | #ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
---|
| 30 | # include "boost/type_traits/is_reference.hpp"
|
---|
| 31 | # include "boost/type_traits/is_array.hpp"
|
---|
| 32 | # include "boost/type_traits/detail/is_function_ptr_tester.hpp"
|
---|
| 33 | # include "boost/type_traits/detail/false_result.hpp"
|
---|
| 34 | # include "boost/type_traits/detail/ice_or.hpp"
|
---|
| 35 | #endif
|
---|
| 36 |
|
---|
| 37 | // should be the last #include
|
---|
| 38 | #include "boost/type_traits/detail/bool_trait_def.hpp"
|
---|
| 39 |
|
---|
| 40 | namespace boost {
|
---|
| 41 |
|
---|
| 42 | #ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
---|
| 43 |
|
---|
| 44 | namespace detail {
|
---|
| 45 |
|
---|
| 46 | template< typename T > struct is_pointer_helper
|
---|
| 47 | {
|
---|
| 48 | BOOST_STATIC_CONSTANT(bool, value = false);
|
---|
| 49 | };
|
---|
| 50 |
|
---|
| 51 | # define TT_AUX_BOOL_TRAIT_HELPER_PARTIAL_SPEC(helper,sp,result) \
|
---|
| 52 | template< typename T > struct helper<sp> \
|
---|
| 53 | { \
|
---|
| 54 | BOOST_STATIC_CONSTANT(bool, value = result); \
|
---|
| 55 | }; \
|
---|
| 56 | /**/
|
---|
| 57 |
|
---|
| 58 | TT_AUX_BOOL_TRAIT_HELPER_PARTIAL_SPEC(is_pointer_helper,T*,true)
|
---|
| 59 | TT_AUX_BOOL_TRAIT_HELPER_PARTIAL_SPEC(is_pointer_helper,T* const,true)
|
---|
| 60 | TT_AUX_BOOL_TRAIT_HELPER_PARTIAL_SPEC(is_pointer_helper,T* volatile,true)
|
---|
| 61 | TT_AUX_BOOL_TRAIT_HELPER_PARTIAL_SPEC(is_pointer_helper,T* const volatile,true)
|
---|
| 62 |
|
---|
| 63 | # undef TT_AUX_BOOL_TRAIT_HELPER_PARTIAL_SPEC
|
---|
| 64 |
|
---|
| 65 | template< typename T >
|
---|
| 66 | struct is_pointer_impl
|
---|
| 67 | {
|
---|
| 68 | BOOST_STATIC_CONSTANT(bool, value =
|
---|
| 69 | (::boost::type_traits::ice_and<
|
---|
| 70 | ::boost::detail::is_pointer_helper<T>::value
|
---|
| 71 | , ::boost::type_traits::ice_not<
|
---|
| 72 | ::boost::is_member_pointer<T>::value
|
---|
| 73 | >::value
|
---|
| 74 | >::value)
|
---|
| 75 | );
|
---|
| 76 | };
|
---|
| 77 |
|
---|
| 78 | } // namespace detail
|
---|
| 79 |
|
---|
| 80 | BOOST_TT_AUX_BOOL_TRAIT_DEF1(is_pointer,T,::boost::detail::is_pointer_impl<T>::value)
|
---|
| 81 |
|
---|
| 82 | #if defined(__BORLANDC__) && !defined(__COMO__) && (__BORLANDC__ < 0x600)
|
---|
| 83 | BOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC1_1(typename T,is_pointer,T&,false)
|
---|
| 84 | BOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC1_1(typename T,is_pointer,T& const,false)
|
---|
| 85 | BOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC1_1(typename T,is_pointer,T& volatile,false)
|
---|
| 86 | BOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC1_1(typename T,is_pointer,T& const volatile,false)
|
---|
| 87 | #endif
|
---|
| 88 |
|
---|
| 89 | #else // no partial template specialization
|
---|
| 90 |
|
---|
| 91 | namespace detail {
|
---|
| 92 |
|
---|
| 93 | struct pointer_helper
|
---|
| 94 | {
|
---|
| 95 | pointer_helper(const volatile void*);
|
---|
| 96 | };
|
---|
| 97 |
|
---|
| 98 | yes_type BOOST_TT_DECL is_pointer_tester(pointer_helper);
|
---|
| 99 | no_type BOOST_TT_DECL is_pointer_tester(...);
|
---|
| 100 |
|
---|
| 101 | template <bool>
|
---|
| 102 | struct is_pointer_select
|
---|
| 103 | : ::boost::type_traits::false_result
|
---|
| 104 | {
|
---|
| 105 | };
|
---|
| 106 |
|
---|
| 107 | template <>
|
---|
| 108 | struct is_pointer_select<false>
|
---|
| 109 | {
|
---|
| 110 | template <typename T> struct result_
|
---|
| 111 | {
|
---|
| 112 | static T& make_t();
|
---|
| 113 | BOOST_STATIC_CONSTANT(bool, value =
|
---|
| 114 | (::boost::type_traits::ice_or<
|
---|
| 115 | (1 == sizeof(is_pointer_tester(make_t()))),
|
---|
| 116 | (1 == sizeof(type_traits::is_function_ptr_tester(make_t())))
|
---|
| 117 | >::value));
|
---|
| 118 | };
|
---|
| 119 | };
|
---|
| 120 |
|
---|
| 121 | template <typename T>
|
---|
| 122 | struct is_pointer_impl
|
---|
| 123 | : is_pointer_select<
|
---|
| 124 | ::boost::type_traits::ice_or<
|
---|
| 125 | ::boost::is_reference<T>::value
|
---|
| 126 | , ::boost::is_array<T>::value
|
---|
| 127 | >::value
|
---|
| 128 | >::template result_<T>
|
---|
| 129 | {
|
---|
| 130 | };
|
---|
| 131 |
|
---|
| 132 | BOOST_TT_AUX_BOOL_TRAIT_IMPL_SPEC1(is_pointer,void,false)
|
---|
| 133 | #ifndef BOOST_NO_CV_VOID_SPECIALIZATIONS
|
---|
| 134 | BOOST_TT_AUX_BOOL_TRAIT_IMPL_SPEC1(is_pointer,void const,false)
|
---|
| 135 | BOOST_TT_AUX_BOOL_TRAIT_IMPL_SPEC1(is_pointer,void volatile,false)
|
---|
| 136 | BOOST_TT_AUX_BOOL_TRAIT_IMPL_SPEC1(is_pointer,void const volatile,false)
|
---|
| 137 | #endif
|
---|
| 138 |
|
---|
| 139 | } // namespace detail
|
---|
| 140 |
|
---|
| 141 | BOOST_TT_AUX_BOOL_TRAIT_DEF1(is_pointer,T,::boost::detail::is_pointer_impl<T>::value)
|
---|
| 142 |
|
---|
| 143 | #endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
---|
| 144 |
|
---|
| 145 | } // namespace boost
|
---|
| 146 |
|
---|
| 147 | #include "boost/type_traits/detail/bool_trait_undef.hpp"
|
---|
| 148 |
|
---|
| 149 | #endif // BOOST_TT_IS_POINTER_HPP_INCLUDED
|
---|