]> git.lyx.org Git - lyx.git/blob - boost/boost/type_traits/is_reference.hpp
Bug: 935
[lyx.git] / boost / boost / type_traits / is_reference.hpp
1
2 //  (C) Copyright David Abrahams Steve Cleary, Beman Dawes, Howard
3 //  Hinnant & John Maddock 2000-2002.  Permission to copy, use,
4 //  modify, 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_REFERENCE_HPP_INCLUDED
12 #define BOOST_TT_IS_REFERENCE_HPP_INCLUDED
13
14 #include "boost/type_traits/config.hpp"
15
16 #ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
17 #   include "boost/type_traits/detail/yes_no_type.hpp"
18 #   include "boost/type_traits/detail/wrap.hpp"
19 #endif
20
21 #if defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) && defined(BOOST_MSVC)
22 #   include "boost/type_traits/detail/is_function_type_tester.hpp"
23 #   include "boost/type_traits/detail/false_result.hpp"
24 #endif
25
26 // should be the last #include
27 #include "boost/type_traits/detail/bool_trait_def.hpp"
28
29 namespace boost { 
30
31 #ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
32
33 BOOST_TT_AUX_BOOL_TRAIT_DEF1(is_reference,T,false)
34 BOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC1_1(typename T,is_reference,T&,true)
35
36 #if defined(__BORLANDC__) && !defined(__COMO__)
37 // these are illegal specialisations; cv-qualifies applied to
38 // references have no effect according to [8.3.2p1],
39 // C++ Builder requires them though as it treats cv-qualified
40 // references as distinct types...
41 BOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC1_1(typename T,is_reference,T& const,true)
42 BOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC1_1(typename T,is_reference,T& volatile,true)
43 BOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC1_1(typename T,is_reference,T& const volatile,true)
44 #endif
45
46 #if defined(__GNUC__) && (__GNUC__ < 3)
47 // these allow us to work around illegally cv-qualified reference
48 // types.
49 BOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC1_1(typename T,is_reference,T const ,::boost::is_reference<T>::value)
50 BOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC1_1(typename T,is_reference,T volatile ,::boost::is_reference<T>::value)
51 BOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC1_1(typename T,is_reference,T const volatile ,::boost::is_reference<T>::value)
52 // However, the above specializations confuse gcc 2.96 unless we also
53 // supply these specializations for array types
54 BOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC1_2(typename T,unsigned long N,is_reference,T[N],false)
55 BOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC1_2(typename T,unsigned long N,is_reference,const T[N],false)
56 BOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC1_2(typename T,unsigned long N,is_reference,volatile T[N],false)
57 BOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC1_2(typename T,unsigned long N,is_reference,const volatile T[N],false)
58 #endif
59
60 #else
61
62 #ifdef BOOST_MSVC
63 #   pragma warning(push)
64 #   pragma warning(disable: 4181)
65 #endif
66
67 namespace detail {
68
69 using ::boost::type_traits::yes_type;
70 using ::boost::type_traits::no_type;
71 using ::boost::type_traits::wrap;
72
73 template <class T> T&(* is_reference_helper1(wrap<T>) )(wrap<T>);
74 char is_reference_helper1(...);
75
76 template <class T> no_type is_reference_helper2(T&(*)(wrap<T>));
77 yes_type is_reference_helper2(...);
78
79 template <typename T>
80 struct is_reference_impl
81 {
82     BOOST_STATIC_CONSTANT(
83         bool, value = sizeof(
84             ::boost::detail::is_reference_helper2(
85                 ::boost::detail::is_reference_helper1(::boost::type_traits::wrap<T>()))) == 1
86         );
87 };
88
89 BOOST_TT_AUX_BOOL_TRAIT_IMPL_SPEC1(is_reference,void,false)
90 #ifndef BOOST_NO_CV_VOID_SPECIALIZATIONS
91 BOOST_TT_AUX_BOOL_TRAIT_IMPL_SPEC1(is_reference,void const,false)
92 BOOST_TT_AUX_BOOL_TRAIT_IMPL_SPEC1(is_reference,void volatile,false)
93 BOOST_TT_AUX_BOOL_TRAIT_IMPL_SPEC1(is_reference,void const volatile,false)
94 #endif
95
96 } // namespace detail
97
98 BOOST_TT_AUX_BOOL_TRAIT_DEF1(is_reference,T,::boost::detail::is_reference_impl<T>::value)
99
100 #ifdef BOOST_MSVC
101 #   pragma warning(pop)
102 #endif
103
104 #endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
105
106 } // namespace boost
107
108 #include "boost/type_traits/detail/bool_trait_undef.hpp"
109
110 #endif // BOOST_TT_IS_REFERENCE_HPP_INCLUDED
111