mirror of
https://github.com/boostorg/optional.git
synced 2025-07-16 13:52:08 +02:00
83 lines
4.2 KiB
HTML
83 lines
4.2 KiB
HTML
![]() |
<html>
|
|||
|
<head>
|
|||
|
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
|||
|
<title>Optional references</title>
|
|||
|
<link rel="stylesheet" href="../boostbook.css" type="text/css">
|
|||
|
<meta name="generator" content="DocBook XSL Stylesheets V1.70.1">
|
|||
|
<link rel="start" href="../index.html" title="Chapter<65>1.<2E>Boost.Optional">
|
|||
|
<link rel="up" href="../index.html" title="Chapter<65>1.<2E>Boost.Optional">
|
|||
|
<link rel="prev" href="examples.html" title="Examples">
|
|||
|
<link rel="next" href="rebinding_semantics_for_assignment_of_optional_references.html" title="Rebinding
|
|||
|
semantics for assignment of optional references">
|
|||
|
</head>
|
|||
|
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
|||
|
<table cellpadding="2" width="100%">
|
|||
|
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../boost.png"></td>
|
|||
|
<td align="center"><a href="../../../index.htm">Home</a></td>
|
|||
|
<td align="center"><a href="../libraries.html">Libraries</a></td>
|
|||
|
<td align="center"><a href="../../../people/people.htm">People</a></td>
|
|||
|
<td align="center"><a href="../../../more/faq.htm">FAQ</a></td>
|
|||
|
<td align="center"><a href="../../../more/index.htm">More</a></td>
|
|||
|
</table>
|
|||
|
<hr>
|
|||
|
<div class="spirit-nav">
|
|||
|
<a accesskey="p" href="examples.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../images/home.png" alt="Home"></a><a accesskey="n" href="rebinding_semantics_for_assignment_of_optional_references.html"><img src="../images/next.png" alt="Next"></a>
|
|||
|
</div>
|
|||
|
<div class="section" lang="en">
|
|||
|
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
|
|||
|
<a name="boost_optional.optional_references"></a><a href="optional_references.html" title="Optional references">Optional references</a>
|
|||
|
</h2></div></div></div>
|
|||
|
<p>
|
|||
|
This library allows the template parameter <code class="computeroutput"><span class="identifier">T</span></code>
|
|||
|
to be of reference type: <code class="computeroutput"><span class="identifier">T</span><span class="special">&</span></code>, and to some extent, <code class="computeroutput"><span class="identifier">T</span>
|
|||
|
<span class="keyword">const</span><span class="special">&</span></code>.
|
|||
|
</p>
|
|||
|
<p>
|
|||
|
However, since references are not real objects some restrictions apply and
|
|||
|
some operations are not available in this case:
|
|||
|
</p>
|
|||
|
<div class="itemizedlist"><ul type="disc">
|
|||
|
<li>
|
|||
|
Converting constructors
|
|||
|
</li>
|
|||
|
<li>
|
|||
|
Converting assignment
|
|||
|
</li>
|
|||
|
<li>
|
|||
|
InPlace construction
|
|||
|
</li>
|
|||
|
<li>
|
|||
|
InPlace assignment
|
|||
|
</li>
|
|||
|
<li>
|
|||
|
Value-access via pointer
|
|||
|
</li>
|
|||
|
</ul></div>
|
|||
|
<p>
|
|||
|
Also, even though <code class="computeroutput"><span class="identifier">optional</span><span class="special"><</span><span class="identifier">T</span><span class="special">&></span></code>
|
|||
|
treats it wrapped pseudo-object much as a real value, a true real reference
|
|||
|
is stored so aliasing will ocurr:
|
|||
|
</p>
|
|||
|
<div class="itemizedlist"><ul type="disc">
|
|||
|
<li>
|
|||
|
Copies of <code class="computeroutput"><span class="identifier">optional</span><span class="special"><</span><span class="identifier">T</span><span class="special">&></span></code>
|
|||
|
will copy the references but all these references will nonetheless reefer
|
|||
|
to the same object.
|
|||
|
</li>
|
|||
|
<li>
|
|||
|
Value-access will actually provide access to the referenced object rather
|
|||
|
than the reference itself.
|
|||
|
</li>
|
|||
|
</ul></div>
|
|||
|
</div>
|
|||
|
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
|||
|
<td align="left"></td>
|
|||
|
<td align="right"><small>Copyright <20> 2003 -2007 Fernando Luis Cacciola Carballal</small></td>
|
|||
|
</tr></table>
|
|||
|
<hr>
|
|||
|
<div class="spirit-nav">
|
|||
|
<a accesskey="p" href="examples.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../images/home.png" alt="Home"></a><a accesskey="n" href="rebinding_semantics_for_assignment_of_optional_references.html"><img src="../images/next.png" alt="Next"></a>
|
|||
|
</div>
|
|||
|
</body>
|
|||
|
</html>
|