blob: 9d8bb4c115faf1a6a4f415de253c1dbe566be4b4 [file] [log] [blame]
Brian Silverman4a2409e2018-08-04 23:24:02 -07001[/
2 Copyright 2007 John Maddock.
3 Distributed under the Boost Software License, Version 1.0.
4 (See accompanying file LICENSE_1_0.txt or copy at
5 http://www.boost.org/LICENSE_1_0.txt).
6]
7
8[section:add_reference add_reference]
9
10[note This trait has been made obsolete by __add_lvalue_reference and __add_rvalue_reference,
11and new code should use these new traits rather than __is_reference which is retained
12for backwards compatibility only.
13]
14
15
16 template <class T>
17 struct add_reference
18 {
19 typedef __below type;
20 };
21
22 template <class T> using add_reference_t = typename add_reference<T>::type; // C++11 and above
23
24__type If `T` is not a reference type then `T&`, otherwise `T`.
25
26__std_ref 8.3.2.
27
28__header ` #include <boost/type_traits/add_reference.hpp>` or ` #include <boost/type_traits.hpp>`
29
30[table Examples
31
32[ [Expression] [Result Type]]
33
34[[`add_reference<int>::type`][`int&`]]
35
36[[`add_reference<int const&>::type`] [`int const&`]]
37
38[[`add_reference<int*>::type`] [`int*&`]]
39
40[[`add_reference<int*&>::type`] [`int*&`]]
41
42]
43
44[all_compilers]
45
46[endsect]
47