source: NonGTP/Boost/boost/type_traits/add_reference.hpp @ 857

Revision 857, 2.4 KB checked in by igarcia, 18 years ago (diff)
Line 
1
2//  (C) Copyright Steve Cleary, Beman Dawes, Howard Hinnant & John Maddock 2000.
3//  Use, modification and distribution are subject to the Boost Software License,
4//  Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
5//  http://www.boost.org/LICENSE_1_0.txt).
6//
7//  See http://www.boost.org/libs/type_traits for most recent version including documentation.
8
9#ifndef BOOST_TT_ADD_REFERENCE_HPP_INCLUDED
10#define BOOST_TT_ADD_REFERENCE_HPP_INCLUDED
11
12#include "boost/type_traits/is_reference.hpp"
13#include "boost/detail/workaround.hpp"
14#include "boost/config.hpp"
15
16// should be the last #include
17#include "boost/type_traits/detail/type_trait_def.hpp"
18
19namespace boost {
20
21namespace detail {
22
23#if defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) && defined(BOOST_MSVC6_MEMBER_TEMPLATES)
24
25template <bool x>
26struct reference_adder
27{
28    template <typename T> struct result_
29    {
30        typedef T& type;
31    };
32};
33
34template <>
35struct reference_adder<true>
36{
37    template <typename T> struct result_
38    {
39        typedef T type;
40    };
41};
42
43template <typename T>
44struct add_reference_impl
45{
46    typedef typename reference_adder<
47          ::boost::is_reference<T>::value
48        >::template result_<T> result;
49
50    typedef typename result::type type;
51};
52
53#else
54
55template <typename T>
56struct add_reference_impl
57{
58    typedef T& type;
59};
60
61#ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
62BOOST_TT_AUX_TYPE_TRAIT_IMPL_PARTIAL_SPEC1_1(typename T,add_reference,T&,T&)
63#endif
64
65#endif
66
67// these full specialisations are always required:
68BOOST_TT_AUX_TYPE_TRAIT_IMPL_SPEC1(add_reference,void,void)
69#ifndef BOOST_NO_CV_VOID_SPECIALIZATIONS
70BOOST_TT_AUX_TYPE_TRAIT_IMPL_SPEC1(add_reference,void const,void const)
71BOOST_TT_AUX_TYPE_TRAIT_IMPL_SPEC1(add_reference,void volatile,void volatile)
72BOOST_TT_AUX_TYPE_TRAIT_IMPL_SPEC1(add_reference,void const volatile,void const volatile)
73#endif
74
75} // namespace detail
76
77BOOST_TT_AUX_TYPE_TRAIT_DEF1(add_reference,T,typename detail::add_reference_impl<T>::type)
78
79// agurt, 07/mar/03: workaround Borland's ill-formed sensitivity to an additional
80// level of indirection, here
81#if BOOST_WORKAROUND(__BORLANDC__, < 0x600)
82BOOST_TT_AUX_TYPE_TRAIT_PARTIAL_SPEC1_1(typename T,add_reference,T&,T&)
83#endif
84
85} // namespace boost
86
87#include "boost/type_traits/detail/type_trait_undef.hpp"
88
89#endif // BOOST_TT_ADD_REFERENCE_HPP_INCLUDED
Note: See TracBrowser for help on using the repository browser.