]> git.lyx.org Git - lyx.git/blob - boost/boost/type_traits/reference_traits.hpp
update boost
[lyx.git] / boost / boost / type_traits / reference_traits.hpp
1 //  (C) Copyright David Abrahams Steve Cleary, Beman Dawes, Howard
2 //  Hinnant & John Maddock 2000-2002.  Permission to copy, use,
3 //  modify, sell and distribute this software is granted provided this
4 //  copyright notice appears in all copies. This software is provided
5 //  "as is" without express or implied warranty, and with no claim as
6 //  to its suitability for any purpose.
7 //
8 //  See http://www.boost.org for most recent version including documentation.
9 //
10 #ifndef BOOST_TT_REFERENCE_TRAITS_HPP
11 # define BOOST_TT_REFERENCE_TRAITS_HPP
12
13 # ifndef BOOST_TT_UTILITY_HPP
14 #  include <boost/type_traits/utility.hpp>
15 # endif // BOOST_TT_UTILITY_HPP
16
17 namespace boost { 
18
19 /**********************************************
20  *
21  * is_reference
22  *
23  **********************************************/
24 #ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
25 template <typename T> struct is_reference 
26 { BOOST_STATIC_CONSTANT(bool, value = false); };
27 template <typename T> struct is_reference<T&> 
28 { BOOST_STATIC_CONSTANT(bool, value = true); };
29 #if defined(__BORLANDC__)
30 // these are illegal specialisations; cv-qualifies applied to
31 // references have no effect according to [8.3.2p1],
32 // C++ Builder requires them though as it treats cv-qualified
33 // references as distinct types...
34 template <typename T> struct is_reference<T&const> 
35 { BOOST_STATIC_CONSTANT(bool, value = true); };
36 template <typename T> struct is_reference<T&volatile> 
37 { BOOST_STATIC_CONSTANT(bool, value = true); };
38 template <typename T> struct is_reference<T&const volatile> 
39 { BOOST_STATIC_CONSTANT(bool, value = true); };
40 #endif
41 #else
42 # ifdef BOOST_MSVC
43 #  pragma warning(push)
44 #  pragma warning(disable: 4181)
45 #endif // BOOST_MSVC
46
47 namespace detail
48 {
49   using ::boost::type_traits::yes_type;
50   using ::boost::type_traits::no_type;
51   using ::boost::type_traits::wrap;
52   
53   template <class T> T&(* is_reference_helper1(wrap<T>) )(wrap<T>);
54   char is_reference_helper1(...);
55
56   template <class T> no_type is_reference_helper2(T&(*)(wrap<T>));
57   yes_type is_reference_helper2(...);
58 }
59
60 template <typename T>
61 struct is_reference
62 {
63     BOOST_STATIC_CONSTANT(
64         bool, value = sizeof(
65             ::boost::detail::is_reference_helper2(
66                 ::boost::detail::is_reference_helper1(::boost::type_traits::wrap<T>()))) == 1
67         );
68 };
69     
70 template <> struct is_reference<void>
71 {
72    BOOST_STATIC_CONSTANT(bool, value = false);
73 };
74 #ifndef BOOST_NO_CV_VOID_SPECIALIZATIONS
75 template <> struct is_reference<const void>
76 { BOOST_STATIC_CONSTANT(bool, value = false); };
77 template <> struct is_reference<volatile void>
78 { BOOST_STATIC_CONSTANT(bool, value = false); };
79 template <> struct is_reference<const volatile void>
80 { BOOST_STATIC_CONSTANT(bool, value = false); };
81 #endif
82
83 # ifdef BOOST_MSVC
84 #  pragma warning(pop)
85 # endif // BOOST_MSVC
86 #endif
87
88 } // namespace boost::type_traits
89
90 #endif // BOOST_TT_REFERENCE_TRAITS_HPP