blob: d82535538a74607b35942f05e7122247159b52a9 [file] [log] [blame]
Jeff Thompsonf7d49942013-08-01 16:47:40 -07001
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
Jeff Thompson2277ce52013-08-01 17:34:11 -070012#include <ndnboost/type_traits/is_reference.hpp>
13#include <ndnboost/detail/workaround.hpp>
14#include <ndnboost/config.hpp>
Jeff Thompsonf7d49942013-08-01 16:47:40 -070015
16// should be the last #include
Jeff Thompson2277ce52013-08-01 17:34:11 -070017#include <ndnboost/type_traits/detail/type_trait_def.hpp>
Jeff Thompsonf7d49942013-08-01 16:47:40 -070018
19namespace ndnboost {
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 ::ndnboost::is_reference<T>::value
48 >::template result_<T> result;
49
50 typedef typename result::type type;
51};
52
53#else
54//
55// We can't filter out rvalue_references at the same level as
56// references or we get ambiguities from msvc:
57//
58
59template <typename T>
60struct add_reference_rvalue_layer
61{
62 typedef T& type;
63};
64
65#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
66template <typename T>
67struct add_reference_rvalue_layer<T&&>
68{
69 typedef T&& type;
70};
71#endif
72
73template <typename T>
74struct add_reference_impl
75{
76 typedef typename add_reference_rvalue_layer<T>::type type;
77};
78
79#ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
80BOOST_TT_AUX_TYPE_TRAIT_IMPL_PARTIAL_SPEC1_1(typename T,add_reference,T&,T&)
81#endif
82
83#endif
84
85// these full specialisations are always required:
86BOOST_TT_AUX_TYPE_TRAIT_IMPL_SPEC1(add_reference,void,void)
87#ifndef BOOST_NO_CV_VOID_SPECIALIZATIONS
88BOOST_TT_AUX_TYPE_TRAIT_IMPL_SPEC1(add_reference,void const,void const)
89BOOST_TT_AUX_TYPE_TRAIT_IMPL_SPEC1(add_reference,void volatile,void volatile)
90BOOST_TT_AUX_TYPE_TRAIT_IMPL_SPEC1(add_reference,void const volatile,void const volatile)
91#endif
92
93} // namespace detail
94
95BOOST_TT_AUX_TYPE_TRAIT_DEF1(add_reference,T,typename ndnboost::detail::add_reference_impl<T>::type)
96
97// agurt, 07/mar/03: workaround Borland's ill-formed sensitivity to an additional
98// level of indirection, here
99#if BOOST_WORKAROUND(__BORLANDC__, < 0x600)
100BOOST_TT_AUX_TYPE_TRAIT_PARTIAL_SPEC1_1(typename T,add_reference,T&,T&)
101#endif
102
103} // namespace ndnboost
104
Jeff Thompson2277ce52013-08-01 17:34:11 -0700105#include <ndnboost/type_traits/detail/type_trait_undef.hpp>
Jeff Thompsonf7d49942013-08-01 16:47:40 -0700106
107#endif // BOOST_TT_ADD_REFERENCE_HPP_INCLUDED