]> git.lyx.org Git - lyx.git/blob - boost/boost/type_traits/is_pointer.hpp
update to boost 1.30.1
[lyx.git] / boost / boost / type_traits / is_pointer.hpp
1
2 // (C) Copyright Dave Abrahams, Steve Cleary, Beman Dawes, Howard
3 // Hinnant & John Maddock 2000.  Permission to copy, use, modify,
4 // sell and distribute this software is granted provided this
5 // copyright notice appears in all copies. This software is provided
6 // "as is" without express or implied warranty, and with no claim as
7 // to its suitability for any purpose.
8 //
9 // See http://www.boost.org for most recent version including documentation.
10
11 #ifndef BOOST_TT_IS_POINTER_HPP_INCLUDED
12 #define BOOST_TT_IS_POINTER_HPP_INCLUDED
13
14 #include "boost/type_traits/is_member_pointer.hpp"
15 #include "boost/type_traits/detail/ice_and.hpp"
16 #include "boost/type_traits/detail/ice_not.hpp"
17 #include "boost/type_traits/config.hpp"
18
19 #ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
20 #   include "boost/type_traits/is_reference.hpp"
21 #   include "boost/type_traits/is_array.hpp"
22 #   include "boost/type_traits/detail/is_function_ptr_tester.hpp"
23 #   include "boost/type_traits/detail/false_result.hpp"
24 #   include "boost/type_traits/detail/ice_or.hpp"
25 #endif
26
27 // should be the last #include
28 #include "boost/type_traits/detail/bool_trait_def.hpp"
29
30 namespace boost {
31
32 #ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
33
34 namespace detail {
35
36 template< typename T > struct is_pointer_helper
37 {
38     BOOST_STATIC_CONSTANT(bool, value = false);
39 };
40
41 #   define TT_AUX_BOOL_TRAIT_HELPER_PARTIAL_SPEC(helper,sp,result) \
42 template< typename T > struct helper<sp> \
43 { \
44     BOOST_STATIC_CONSTANT(bool, value = result); \
45 }; \
46 /**/
47
48 TT_AUX_BOOL_TRAIT_HELPER_PARTIAL_SPEC(is_pointer_helper,T*,true)
49 TT_AUX_BOOL_TRAIT_HELPER_PARTIAL_SPEC(is_pointer_helper,T* const,true)
50 TT_AUX_BOOL_TRAIT_HELPER_PARTIAL_SPEC(is_pointer_helper,T* volatile,true)
51 TT_AUX_BOOL_TRAIT_HELPER_PARTIAL_SPEC(is_pointer_helper,T* const volatile,true)
52
53 #   undef TT_AUX_BOOL_TRAIT_HELPER_PARTIAL_SPEC
54
55 template< typename T >
56 struct is_pointer_impl
57 {
58     BOOST_STATIC_CONSTANT(bool, value = 
59         (::boost::type_traits::ice_and<
60               ::boost::detail::is_pointer_helper<T>::value
61             , ::boost::type_traits::ice_not<
62                 ::boost::is_member_pointer<T>::value
63                 >::value
64             >::value)
65         );
66 };
67
68 } // namespace detail
69
70 BOOST_TT_AUX_BOOL_TRAIT_DEF1(is_pointer,T,::boost::detail::is_pointer_impl<T>::value)
71
72 #if defined(__BORLANDC__) && !defined(__COMO__)
73 BOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC1_1(typename T,is_pointer,T&,false)
74 BOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC1_1(typename T,is_pointer,T& const,false)
75 BOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC1_1(typename T,is_pointer,T& volatile,false)
76 BOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC1_1(typename T,is_pointer,T& const volatile,false)
77 #endif
78
79 #else // no partial template specialization
80
81 namespace detail {
82
83 struct pointer_helper
84 {
85     pointer_helper(const volatile void*);
86 };
87
88 yes_type BOOST_TT_DECL is_pointer_tester(pointer_helper);
89 no_type BOOST_TT_DECL is_pointer_tester(...);
90
91 template <bool>
92 struct is_pointer_select
93     : ::boost::type_traits::false_result
94 {
95 };
96
97 template <>
98 struct is_pointer_select<false>
99 {
100     template <typename T> struct result_
101     {
102         static T& make_t();
103         BOOST_STATIC_CONSTANT(bool, value =
104                 (::boost::type_traits::ice_or<
105                     (1 == sizeof(is_pointer_tester(make_t()))),
106                     (1 == sizeof(type_traits::is_function_ptr_tester(make_t())))
107                 >::value));
108     };
109 };
110
111 template <typename T>
112 struct is_pointer_impl
113     : is_pointer_select<
114           ::boost::type_traits::ice_or<
115               ::boost::is_reference<T>::value
116             , ::boost::is_array<T>::value
117             >::value
118         >::template result_<T>
119 {
120 };
121
122 BOOST_TT_AUX_BOOL_TRAIT_IMPL_SPEC1(is_pointer,void,false)
123 #ifndef BOOST_NO_CV_VOID_SPECIALIZATIONS
124 BOOST_TT_AUX_BOOL_TRAIT_IMPL_SPEC1(is_pointer,void const,false)
125 BOOST_TT_AUX_BOOL_TRAIT_IMPL_SPEC1(is_pointer,void volatile,false)
126 BOOST_TT_AUX_BOOL_TRAIT_IMPL_SPEC1(is_pointer,void const volatile,false)
127 #endif
128
129 } // namespace detail
130
131 BOOST_TT_AUX_BOOL_TRAIT_DEF1(is_pointer,T,::boost::detail::is_pointer_impl<T>::value)
132
133 #endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
134
135 } // namespace boost
136
137 #include "boost/type_traits/detail/bool_trait_undef.hpp"
138
139 #endif // BOOST_TT_IS_POINTER_HPP_INCLUDED