fixing stuff
[dyninst.git] / dynutil / h / dyn_detail / boost / type_traits / is_reference.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_REFERENCE_HPP_INCLUDED
22 #define DYN_DETAIL_BOOST_TT_IS_REFERENCE_HPP_INCLUDED
23
24 #include <dyn_detail/boost/type_traits/config.hpp>
25
26 #ifdef DYN_DETAIL_BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
27 #   include <dyn_detail/boost/type_traits/detail/yes_no_type.hpp>
28 #   include <dyn_detail/boost/type_traits/detail/wrap.hpp>
29 #endif
30
31 // should be the last #include
32 #include <dyn_detail/boost/type_traits/detail/bool_trait_def.hpp>
33
34 namespace dyn_detail {
35 namespace boost {
36
37 #if defined( __CODEGEARC__ )
38 DYN_DETAIL_BOOST_TT_AUX_BOOL_TRAIT_DEF1(is_reference,T,__is_reference(T))
39 #elif !defined(DYN_DETAIL_BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
40
41 DYN_DETAIL_BOOST_TT_AUX_BOOL_TRAIT_DEF1(is_reference,T,false)
42 DYN_DETAIL_BOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC1_1(typename T,is_reference,T&,true)
43
44 #if  defined(DYN_DETAIL_BOOST_ILLEGAL_CV_REFERENCES)
45 // these are illegal specialisations; cv-qualifies applied to
46 // references have no effect according to [8.3.2p1],
47 // C++ Builder requires them though as it treats cv-qualified
48 // references as distinct types...
49 DYN_DETAIL_BOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC1_1(typename T,is_reference,T& const,true)
50 DYN_DETAIL_BOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC1_1(typename T,is_reference,T& volatile,true)
51 DYN_DETAIL_BOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC1_1(typename T,is_reference,T& const volatile,true)
52 #endif
53
54 #if defined(__GNUC__) && (__GNUC__ < 3)
55 // these allow us to work around illegally cv-qualified reference
56 // types.
57 DYN_DETAIL_BOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC1_1(typename T,is_reference,T const ,dyn_detail::boost::is_reference<T>::value)
58 DYN_DETAIL_BOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC1_1(typename T,is_reference,T volatile ,dyn_detail::boost::is_reference<T>::value)
59 DYN_DETAIL_BOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC1_1(typename T,is_reference,T const volatile ,dyn_detail::boost::is_reference<T>::value)
60 // However, the above specializations confuse gcc 2.96 unless we also
61 // supply these specializations for array types
62 DYN_DETAIL_BOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC1_2(typename T,unsigned long N,is_reference,T[N],false)
63 DYN_DETAIL_BOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC1_2(typename T,unsigned long N,is_reference,const T[N],false)
64 DYN_DETAIL_BOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC1_2(typename T,unsigned long N,is_reference,volatile T[N],false)
65 DYN_DETAIL_BOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC1_2(typename T,unsigned long N,is_reference,const volatile T[N],false)
66 #endif
67
68 #else
69
70 #ifdef DYN_DETAIL_BOOST_MSVC
71 #   pragma warning(push)
72 #   pragma warning(disable: 4181 4097)
73 #endif
74
75 namespace detail {
76
77 using dyn_detail::boost::type_traits::yes_type;
78 using dyn_detail::boost::type_traits::no_type;
79 using dyn_detail::boost::type_traits::wrap;
80
81 template <class T> T&(* is_reference_helper1(wrap<T>) )(wrap<T>);
82 char is_reference_helper1(...);
83
84 template <class T> no_type is_reference_helper2(T&(*)(wrap<T>));
85 yes_type is_reference_helper2(...);
86
87 template <typename T>
88 struct is_reference_impl
89 {
90     DYN_DETAIL_BOOST_STATIC_CONSTANT(
91         bool, value = sizeof(
92             dyn_detail::boost::detail::is_reference_helper2(
93                 dyn_detail::boost::detail::is_reference_helper1(dyn_detail::boost::type_traits::wrap<T>()))) == 1
94         );
95 };
96
97 DYN_DETAIL_BOOST_TT_AUX_BOOL_TRAIT_IMPL_SPEC1(is_reference,void,false)
98 #ifndef DYN_DETAIL_BOOST_NO_CV_VOID_SPECIALIZATIONS
99 DYN_DETAIL_BOOST_TT_AUX_BOOL_TRAIT_IMPL_SPEC1(is_reference,void const,false)
100 DYN_DETAIL_BOOST_TT_AUX_BOOL_TRAIT_IMPL_SPEC1(is_reference,void volatile,false)
101 DYN_DETAIL_BOOST_TT_AUX_BOOL_TRAIT_IMPL_SPEC1(is_reference,void const volatile,false)
102 #endif
103
104 } // namespace detail
105
106 DYN_DETAIL_BOOST_TT_AUX_BOOL_TRAIT_DEF1(is_reference,T,dyn_detail::boost::detail::is_reference_impl<T>::value)
107
108 #ifdef DYN_DETAIL_BOOST_MSVC
109 #   pragma warning(pop)
110 #endif
111
112 #endif // DYN_DETAIL_BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
113
114 } // namespace boost
115 } // namespace dyn_detail
116
117 #include <dyn_detail/boost/type_traits/detail/bool_trait_undef.hpp>
118
119 #endif // DYN_DETAIL_BOOST_TT_IS_REFERENCE_HPP_INCLUDED
120