]>
Commit | Line | Data |
---|---|---|
1 | [/ | |
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, | |
11 | and new code should use these new traits rather than __is_reference which is retained | |
12 | for backwards compatibility only. | |
13 | ] | |
14 | ||
15 | ||
16 | template <class T> | |
17 | struct add_reference | |
18 | { | |
19 | typedef __below type; | |
20 | }; | |
21 | ||
22 | __type If `T` is not a reference type then `T&`, otherwise `T`. | |
23 | ||
24 | __std_ref 8.3.2. | |
25 | ||
26 | __header ` #include <boost/type_traits/add_reference.hpp>` or ` #include <boost/type_traits.hpp>` | |
27 | ||
28 | [table Examples | |
29 | ||
30 | [ [Expression] [Result Type]] | |
31 | ||
32 | [[`add_reference<int>::type`][`int&`]] | |
33 | ||
34 | [[`add_reference<int const&>::type`] [`int const&`]] | |
35 | ||
36 | [[`add_reference<int*>::type`] [`int*&`]] | |
37 | ||
38 | [[`add_reference<int*&>::type`] [`int*&`]] | |
39 | ||
40 | ] | |
41 | ||
42 | [all_compilers] | |
43 | ||
44 | [endsect] | |
45 |