fixing stuff
[dyninst.git] / dynutil / h / dyn_detail / boost / type_traits / is_pointer.hpp
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 DYN_DETAIL_BOOST_TT_IS_POINTER_HPP_INCLUDED
22 #define DYN_DETAIL_BOOST_TT_IS_POINTER_HPP_INCLUDED
23
24 #include <dyn_detail/boost/type_traits/is_member_pointer.hpp>
25 #include <dyn_detail/boost/type_traits/detail/ice_and.hpp>
26 #include <dyn_detail/boost/type_traits/detail/ice_not.hpp>
27 #include <dyn_detail/boost/type_traits/config.hpp>
28 #if !DYN_DETAIL_BOOST_WORKAROUND(DYN_DETAIL_BOOST_MSVC,<=1300)
29 #include <dyn_detail/boost/type_traits/remove_cv.hpp>
30 #endif
31
32 #ifdef DYN_DETAIL_BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
33 #   include <dyn_detail/boost/type_traits/is_reference.hpp>
34 #   include <dyn_detail/boost/type_traits/is_array.hpp>
35 #   include <dyn_detail/boost/type_traits/detail/is_function_ptr_tester.hpp>
36 #   include <dyn_detail/boost/type_traits/detail/false_result.hpp>
37 #   include <dyn_detail/boost/type_traits/detail/ice_or.hpp>
38 #endif
39
40 // should be the last #include
41 #include <dyn_detail/boost/type_traits/detail/bool_trait_def.hpp>
42
43 namespace dyn_detail {
44 namespace boost {
45
46 #if defined( __CODEGEARC__ )
47 DYN_DETAIL_BOOST_TT_AUX_BOOL_TRAIT_DEF1(is_pointer,T,__is_pointer(T))
48 #elif !defined(DYN_DETAIL_BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
49
50 namespace detail {
51
52 template< typename T > struct is_pointer_helper
53 {
54     DYN_DETAIL_BOOST_STATIC_CONSTANT(bool, value = false);
55 };
56
57 #   define TT_AUX_BOOL_TRAIT_HELPER_PARTIAL_SPEC(helper,sp,result) \
58 template< typename T > struct helper<sp> \
59 { \
60     DYN_DETAIL_BOOST_STATIC_CONSTANT(bool, value = result); \
61 }; \
62 /**/
63
64 TT_AUX_BOOL_TRAIT_HELPER_PARTIAL_SPEC(is_pointer_helper,T*,true)
65
66 #   undef TT_AUX_BOOL_TRAIT_HELPER_PARTIAL_SPEC
67
68 template< typename T >
69 struct is_pointer_impl
70 {
71 #if DYN_DETAIL_BOOST_WORKAROUND(DYN_DETAIL_BOOST_MSVC,<=1300)
72     DYN_DETAIL_BOOST_STATIC_CONSTANT(bool, value =
73         (::dyn_detail::boost::type_traits::ice_and<
74               ::dyn_detail::boost::detail::is_pointer_helper<T>::value
75             , ::dyn_detail::boost::type_traits::ice_not<
76                 ::dyn_detail::boost::is_member_pointer<T>::value
77                 >::value
78             >::value)
79         );
80 #else
81     DYN_DETAIL_BOOST_STATIC_CONSTANT(bool, value =
82         (::dyn_detail::boost::type_traits::ice_and<
83         ::dyn_detail::boost::detail::is_pointer_helper<typename remove_cv<T>::type>::value
84             , ::dyn_detail::boost::type_traits::ice_not<
85                 ::dyn_detail::boost::is_member_pointer<T>::value
86                 >::value
87             >::value)
88         );
89 #endif
90 };
91
92 } // namespace detail
93
94 DYN_DETAIL_BOOST_TT_AUX_BOOL_TRAIT_DEF1(is_pointer,T,::dyn_detail::boost::detail::is_pointer_impl<T>::value)
95
96 #if defined(__BORLANDC__) && !defined(__COMO__) && (__BORLANDC__ < 0x600)
97 DYN_DETAIL_BOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC1_1(typename T,is_pointer,T&,false)
98 DYN_DETAIL_BOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC1_1(typename T,is_pointer,T& const,false)
99 DYN_DETAIL_BOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC1_1(typename T,is_pointer,T& volatile,false)
100 DYN_DETAIL_BOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC1_1(typename T,is_pointer,T& const volatile,false)
101 #endif
102
103 #else // no partial template specialization
104
105 namespace detail {
106
107 struct pointer_helper
108 {
109     pointer_helper(const volatile void*);
110 };
111
112 yes_type DYN_DETAIL_BOOST_TT_DECL is_pointer_tester(pointer_helper);
113 no_type DYN_DETAIL_BOOST_TT_DECL is_pointer_tester(...);
114
115 template <bool>
116 struct is_pointer_select
117     : ::dyn_detail::boost::type_traits::false_result
118 {
119 };
120
121 template <>
122 struct is_pointer_select<false>
123 {
124     template <typename T> struct result_
125     {
126         static T& make_t();
127         DYN_DETAIL_BOOST_STATIC_CONSTANT(bool, value =
128                 (::dyn_detail::boost::type_traits::ice_or<
129                     (1 == sizeof(is_pointer_tester(make_t()))),
130                     (1 == sizeof(type_traits::is_function_ptr_tester(make_t())))
131                 >::value));
132     };
133 };
134
135 template <typename T>
136 struct is_pointer_impl
137     : is_pointer_select<
138           ::dyn_detail::boost::type_traits::ice_or<
139               ::dyn_detail::boost::is_reference<T>::value
140             , ::dyn_detail::boost::is_array<T>::value
141             >::value
142         >::template result_<T>
143 {
144 };
145
146 DYN_DETAIL_BOOST_TT_AUX_BOOL_TRAIT_IMPL_SPEC1(is_pointer,void,false)
147 #ifndef DYN_DETAIL_BOOST_NO_CV_VOID_SPECIALIZATIONS
148 DYN_DETAIL_BOOST_TT_AUX_BOOL_TRAIT_IMPL_SPEC1(is_pointer,void const,false)
149 DYN_DETAIL_BOOST_TT_AUX_BOOL_TRAIT_IMPL_SPEC1(is_pointer,void volatile,false)
150 DYN_DETAIL_BOOST_TT_AUX_BOOL_TRAIT_IMPL_SPEC1(is_pointer,void const volatile,false)
151 #endif
152
153 } // namespace detail
154
155 DYN_DETAIL_BOOST_TT_AUX_BOOL_TRAIT_DEF1(is_pointer,T,::dyn_detail::boost::detail::is_pointer_impl<T>::value)
156
157 #endif // DYN_DETAIL_BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
158
159 } // namespace boost
160 } // namespace dyn_detail
161
162 #include <dyn_detail/boost/type_traits/detail/bool_trait_undef.hpp>
163
164 #endif // DYN_DETAIL_BOOST_TT_IS_POINTER_HPP_INCLUDED