• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1<html>
2<head>
3<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
4<title>Class template reference_wrapper</title>
5<link rel="stylesheet" href="../../../../../doc/src/boostbook.css" type="text/css">
6<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
7<link rel="home" href="../index.html" title="Chapter 1. Boost.Core">
8<link rel="up" href="../core/ref.html#header.boost.core.ref_hpp" title="Header &lt;boost/core/ref.hpp&gt;">
9<link rel="prev" href="is_reference_wrapper.html" title="Struct template is_reference_wrapper">
10<link rel="next" href="unwrap_reference.html" title="Struct template unwrap_reference">
11</head>
12<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
13<table cellpadding="2" width="100%"><tr>
14<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../boost.png"></td>
15<td align="center"><a href="../../../../../index.html">Home</a></td>
16<td align="center"><a href="../../../../../libs/libraries.htm">Libraries</a></td>
17<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
18<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
19<td align="center"><a href="../../../../../more/index.htm">More</a></td>
20</tr></table>
21<hr>
22<div class="spirit-nav">
23<a accesskey="p" href="is_reference_wrapper.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../core/ref.html#header.boost.core.ref_hpp"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="unwrap_reference.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
24</div>
25<div class="refentry">
26<a name="boost.reference_wrapper"></a><div class="titlepage"></div>
27<div class="refnamediv">
28<h2><span class="refentrytitle">Class template reference_wrapper</span></h2>
29<p>boost::reference_wrapper — Contains a reference to an object of type <code class="computeroutput">T</code>. </p>
30</div>
31<h2 xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="refsynopsisdiv-title">Synopsis</h2>
32<div xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="refsynopsisdiv"><pre class="synopsis"><span class="comment">// In header: &lt;<a class="link" href="../core/ref.html#header.boost.core.ref_hpp" title="Header &lt;boost/core/ref.hpp&gt;">boost/core/ref.hpp</a>&gt;
33
34</span><span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> T<span class="special">&gt;</span>
35<span class="keyword">class</span> <a class="link" href="reference_wrapper.html" title="Class template reference_wrapper">reference_wrapper</a> <span class="special">{</span>
36<span class="keyword">public</span><span class="special">:</span>
37  <span class="comment">// <a class="link" href="reference_wrapper.html#boost.reference_wrappertypes">types</a></span>
38  <span class="keyword">typedef</span> <span class="identifier">T</span> <a class="link" href="reference_wrapper.html#boost.reference_wrapper.type"><span class="identifier">type</span></a><span class="special">;</span>
39
40  <span class="comment">// <a class="link" href="reference_wrapper.html#boost.reference_wrapperconstruct-copy-destruct">construct/copy/destruct</a></span>
41  <span class="keyword">explicit</span> <a class="link" href="reference_wrapper.html#idm45442566544128-bb"><span class="identifier">reference_wrapper</span></a><span class="special">(</span><span class="identifier">T</span> <span class="special">&amp;</span><span class="special">)</span><span class="special">;</span>
42  <a class="link" href="reference_wrapper.html#idm45442566540560-bb"><span class="identifier">reference_wrapper</span></a><span class="special">(</span><span class="identifier">T</span> <span class="special">&amp;&amp;</span><span class="special">)</span> <span class="special">=</span> <span class="keyword">delete</span><span class="special">;</span>
43
44  <span class="comment">// <a class="link" href="reference_wrapper.html#idm45442566552672-bb">public member functions</a></span>
45  <a class="link" href="reference_wrapper.html#idm45442566552112-bb"><span class="keyword">operator</span> <span class="identifier">T</span> <span class="special">&amp;</span></a><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
46  <span class="identifier">T</span> <span class="special">&amp;</span> <a class="link" href="reference_wrapper.html#idm45442566549552-bb"><span class="identifier">get</span></a><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
47  <span class="identifier">T</span> <span class="special">*</span> <a class="link" href="reference_wrapper.html#idm45442566546816-bb"><span class="identifier">get_pointer</span></a><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
48<span class="special">}</span><span class="special">;</span></pre></div>
49<div class="refsect1">
50<a name="idm45312826407648"></a><h2>Description</h2>
51<p><code class="computeroutput"><a class="link" href="reference_wrapper.html" title="Class template reference_wrapper">reference_wrapper</a></code> is primarily used to "feed" references to function templates (algorithms) that take their parameter by value. It provides an implicit conversion to <code class="computeroutput">T&amp;</code>, which usually allows the function templates to work on references unmodified. </p>
52<div class="refsect2">
53<a name="idm45312826405056"></a><h3>
54<a name="boost.reference_wrappertypes"></a><code class="computeroutput">reference_wrapper</code>
55        public
56       types</h3>
57<div class="orderedlist"><ol class="orderedlist" type="1"><li class="listitem">
58<p>
59<span class="keyword">typedef</span> <span class="identifier">T</span> <a name="boost.reference_wrapper.type"></a><span class="identifier">type</span><span class="special">;</span></p>
60<p>Type <code class="computeroutput">T</code>. </p>
61</li></ol></div>
62</div>
63<div class="refsect2">
64<a name="idm45312826398464"></a><h3>
65<a name="boost.reference_wrapperconstruct-copy-destruct"></a><code class="computeroutput">reference_wrapper</code>
66        public
67       construct/copy/destruct</h3>
68<div class="orderedlist"><ol class="orderedlist" type="1">
69<li class="listitem">
70<pre class="literallayout"><span class="keyword">explicit</span> <a name="idm45442566544128-bb"></a><span class="identifier">reference_wrapper</span><span class="special">(</span><span class="identifier">T</span> <span class="special">&amp;</span> t<span class="special">)</span><span class="special">;</span></pre>
71<p>Constructs a <code class="computeroutput"><code class="computeroutput"><a class="link" href="reference_wrapper.html" title="Class template reference_wrapper">reference_wrapper</a></code></code> object that stores a reference to <code class="computeroutput">t</code>.</p>
72<p>Does not throw. </p>
73<p>
74
75</p>
76</li>
77<li class="listitem">
78<pre class="literallayout"><a name="idm45442566540560-bb"></a><span class="identifier">reference_wrapper</span><span class="special">(</span><span class="identifier">T</span> <span class="special">&amp;&amp;</span> t<span class="special">)</span> <span class="special">=</span> <span class="keyword">delete</span><span class="special">;</span></pre>
79<p>Construction from a temporary object is disabled. </p>
80<p>
81
82</p>
83</li>
84</ol></div>
85</div>
86<div class="refsect2">
87<a name="idm45312826380512"></a><h3>
88<a name="idm45442566552672-bb"></a><code class="computeroutput">reference_wrapper</code> public member functions</h3>
89<div class="orderedlist"><ol class="orderedlist" type="1">
90<li class="listitem">
91<pre class="literallayout"><a name="idm45442566552112-bb"></a><span class="keyword">operator</span> <span class="identifier">T</span> <span class="special">&amp;</span><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span></pre>
92<p>
93</p>
94<p>Does not throw. </p>
95<p>
96
97</p>
98<div class="variablelist"><table border="0" class="variablelist compact">
99<colgroup>
100<col align="left" valign="top">
101<col>
102</colgroup>
103<tbody><tr>
104<td><p><span class="term">Returns:</span></p></td>
105<td><p>The stored reference. </p></td>
106</tr></tbody>
107</table></div>
108</li>
109<li class="listitem">
110<pre class="literallayout"><span class="identifier">T</span> <span class="special">&amp;</span> <a name="idm45442566549552-bb"></a><span class="identifier">get</span><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span></pre>
111<p>
112</p>
113<p>Does not throw. </p>
114<p>
115
116</p>
117<div class="variablelist"><table border="0" class="variablelist compact">
118<colgroup>
119<col align="left" valign="top">
120<col>
121</colgroup>
122<tbody><tr>
123<td><p><span class="term">Returns:</span></p></td>
124<td><p>The stored reference. </p></td>
125</tr></tbody>
126</table></div>
127</li>
128<li class="listitem">
129<pre class="literallayout"><span class="identifier">T</span> <span class="special">*</span> <a name="idm45442566546816-bb"></a><span class="identifier">get_pointer</span><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span></pre>
130<p>
131</p>
132<p>Does not throw. </p>
133<p>
134
135</p>
136<div class="variablelist"><table border="0" class="variablelist compact">
137<colgroup>
138<col align="left" valign="top">
139<col>
140</colgroup>
141<tbody><tr>
142<td><p><span class="term">Returns:</span></p></td>
143<td><p>A pointer to the object referenced by the stored reference. </p></td>
144</tr></tbody>
145</table></div>
146</li>
147</ol></div>
148</div>
149</div>
150</div>
151<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
152<td align="left"></td>
153<td align="right"><div class="copyright-footer">Copyright © 2014 Peter Dimov<br>Copyright © 2014 Glen Fernandes<br>Copyright © 2014 Andrey Semashev<p>
154        Distributed under the <a href="http://boost.org/LICENSE_1_0.txt" target="_top">Boost
155        Software License, Version 1.0</a>.
156      </p>
157</div></td>
158</tr></table>
159<hr>
160<div class="spirit-nav">
161<a accesskey="p" href="is_reference_wrapper.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../core/ref.html#header.boost.core.ref_hpp"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="unwrap_reference.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
162</div>
163</body>
164</html>
165