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.
8 // See http://www.boost.org for most recent version including documentation.
10 #ifndef BOOST_TT_REFERENCE_TRAITS_HPP
11 # define BOOST_TT_REFERENCE_TRAITS_HPP
13 # ifndef BOOST_TT_UTILITY_HPP
14 # include <boost/type_traits/utility.hpp>
15 # endif // BOOST_TT_UTILITY_HPP
19 /**********************************************
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); };
43 # pragma warning(push)
44 # pragma warning(disable: 4181)
49 using ::boost::type_traits::yes_type;
50 using ::boost::type_traits::no_type;
51 using ::boost::type_traits::wrap;
53 template <class T> T&(* is_reference_helper1(wrap<T>) )(wrap<T>);
54 char is_reference_helper1(...);
56 template <class T> no_type is_reference_helper2(T&(*)(wrap<T>));
57 yes_type is_reference_helper2(...);
63 BOOST_STATIC_CONSTANT(
65 ::boost::detail::is_reference_helper2(
66 ::boost::detail::is_reference_helper1(::boost::type_traits::wrap<T>()))) == 1
70 template <> struct is_reference<void>
72 BOOST_STATIC_CONSTANT(bool, value = false);
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); };
88 } // namespace boost::type_traits
90 #endif // BOOST_TT_REFERENCE_TRAITS_HPP