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
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).
10 // See http://www.boost.org/libs/type_traits for most recent version including documentation.
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).
21 #ifndef BOOST_TT_IS_POINTER_HPP_INCLUDED
22 #define BOOST_TT_IS_POINTER_HPP_INCLUDED
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 #if !BOOST_WORKAROUND(BOOST_MSVC,<=1300)
29 #include <boost/type_traits/remove_cv.hpp>
32 #ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
33 # include <boost/type_traits/is_reference.hpp>
34 # include <boost/type_traits/is_array.hpp>
35 # include <boost/type_traits/detail/is_function_ptr_tester.hpp>
36 # include <boost/type_traits/detail/false_result.hpp>
37 # include <boost/type_traits/detail/ice_or.hpp>
40 // should be the last #include
41 #include <boost/type_traits/detail/bool_trait_def.hpp>
45 #ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
49 template< typename T > struct is_pointer_helper
51 BOOST_STATIC_CONSTANT(bool, value = false);
54 # define TT_AUX_BOOL_TRAIT_HELPER_PARTIAL_SPEC(helper,sp,result) \
55 template< typename T > struct helper<sp> \
57 BOOST_STATIC_CONSTANT(bool, value = result); \
61 TT_AUX_BOOL_TRAIT_HELPER_PARTIAL_SPEC(is_pointer_helper,T*,true)
63 # undef TT_AUX_BOOL_TRAIT_HELPER_PARTIAL_SPEC
65 template< typename T >
66 struct is_pointer_impl
68 #if BOOST_WORKAROUND(BOOST_MSVC,<=1300)
69 BOOST_STATIC_CONSTANT(bool, value =
70 (::boost::type_traits::ice_and<
71 ::boost::detail::is_pointer_helper<T>::value
72 , ::boost::type_traits::ice_not<
73 ::boost::is_member_pointer<T>::value
78 BOOST_STATIC_CONSTANT(bool, value =
79 (::boost::type_traits::ice_and<
80 ::boost::detail::is_pointer_helper<typename remove_cv<T>::type>::value
81 , ::boost::type_traits::ice_not<
82 ::boost::is_member_pointer<T>::value
91 BOOST_TT_AUX_BOOL_TRAIT_DEF1(is_pointer,T,::boost::detail::is_pointer_impl<T>::value)
93 #if defined(__BORLANDC__) && !defined(__COMO__) && (__BORLANDC__ < 0x600)
94 BOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC1_1(typename T,is_pointer,T&,false)
95 BOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC1_1(typename T,is_pointer,T& const,false)
96 BOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC1_1(typename T,is_pointer,T& volatile,false)
97 BOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC1_1(typename T,is_pointer,T& const volatile,false)
100 #else // no partial template specialization
104 struct pointer_helper
106 pointer_helper(const volatile void*);
109 yes_type BOOST_TT_DECL is_pointer_tester(pointer_helper);
110 no_type BOOST_TT_DECL is_pointer_tester(...);
113 struct is_pointer_select
114 : ::boost::type_traits::false_result
119 struct is_pointer_select<false>
121 template <typename T> struct result_
124 BOOST_STATIC_CONSTANT(bool, value =
125 (::boost::type_traits::ice_or<
126 (1 == sizeof(is_pointer_tester(make_t()))),
127 (1 == sizeof(type_traits::is_function_ptr_tester(make_t())))
132 template <typename T>
133 struct is_pointer_impl
135 ::boost::type_traits::ice_or<
136 ::boost::is_reference<T>::value
137 , ::boost::is_array<T>::value
139 >::template result_<T>
143 BOOST_TT_AUX_BOOL_TRAIT_IMPL_SPEC1(is_pointer,void,false)
144 #ifndef BOOST_NO_CV_VOID_SPECIALIZATIONS
145 BOOST_TT_AUX_BOOL_TRAIT_IMPL_SPEC1(is_pointer,void const,false)
146 BOOST_TT_AUX_BOOL_TRAIT_IMPL_SPEC1(is_pointer,void volatile,false)
147 BOOST_TT_AUX_BOOL_TRAIT_IMPL_SPEC1(is_pointer,void const volatile,false)
150 } // namespace detail
152 BOOST_TT_AUX_BOOL_TRAIT_DEF1(is_pointer,T,::boost::detail::is_pointer_impl<T>::value)
154 #endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
158 #include <boost/type_traits/detail/bool_trait_undef.hpp>
160 #endif // BOOST_TT_IS_POINTER_HPP_INCLUDED