mirror of
https://github.com/boostorg/optional.git
synced 2025-06-26 20:41:44 +02:00
Compare commits
1 Commits
svn-branch
...
svn-branch
Author | SHA1 | Date | |
---|---|---|---|
2c839e600b |
@ -12,8 +12,6 @@
|
|||||||
|
|
||||||
import quickbook ;
|
import quickbook ;
|
||||||
|
|
||||||
path-constant images : html ;
|
|
||||||
|
|
||||||
xml optional
|
xml optional
|
||||||
:
|
:
|
||||||
optional.qbk
|
optional.qbk
|
||||||
@ -24,12 +22,9 @@ boostbook standalone
|
|||||||
optional
|
optional
|
||||||
:
|
:
|
||||||
<xsl:param>boost.root=../../../..
|
<xsl:param>boost.root=../../../..
|
||||||
<xsl:param>html.stylesheet=boostbook.css
|
<xsl:param>boost.libraries=../../../libraries.htm
|
||||||
<xsl:param>toc.max.depth=2
|
<xsl:param>toc.max.depth=2
|
||||||
<xsl:param>toc.section.depth=2
|
<xsl:param>toc.section.depth=2
|
||||||
<xsl:param>chunk.section.depth=1
|
<xsl:param>chunk.section.depth=1
|
||||||
<format>pdf:<xsl:param>img.src.path=$(images)/
|
|
||||||
<format>pdf:<xsl:param>boost.url.prefix=http://www.boost.org/doc/libs/release/libs/optional/doc/html
|
|
||||||
;
|
;
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
[/
|
[/
|
||||||
Boost.Optional
|
Boost.Optional
|
||||||
|
|
||||||
Copyright (c) 2003-2007 Fernando Luis Cacciola Carballal
|
Copyright (c) 2003-2007 Fernando Luis Cacciola Carballal
|
||||||
@ -58,7 +58,7 @@ The observation made in the last paragraph about the irrelevant nature of the
|
|||||||
additional `nil_t` with respect to [_purpose] of `optional<T>` suggests an
|
additional `nil_t` with respect to [_purpose] of `optional<T>` suggests an
|
||||||
alternative model: a ['container] that either has a value of `T` or nothing.
|
alternative model: a ['container] that either has a value of `T` or nothing.
|
||||||
|
|
||||||
As of this writing I don't know of any precedent for a variable-size
|
As of this writing I don't know of any precedence for a variable-size
|
||||||
fixed-capacity (of 1) stack-based container model for optional values, yet I
|
fixed-capacity (of 1) stack-based container model for optional values, yet I
|
||||||
believe this is the consequence of the lack of practical implementations of
|
believe this is the consequence of the lack of practical implementations of
|
||||||
such a container rather than an inherent shortcoming of the container model.
|
such a container rather than an inherent shortcoming of the container model.
|
||||||
@ -176,14 +176,14 @@ untitialized optional objects: The operators * and ->]
|
|||||||
A relevant feature of a pointer is that it can have a [*null pointer value].
|
A relevant feature of a pointer is that it can have a [*null pointer value].
|
||||||
This is a ['special] value which is used to indicate that the pointer is not
|
This is a ['special] value which is used to indicate that the pointer is not
|
||||||
referring to any object at all. In other words, null pointer values convey
|
referring to any object at all. In other words, null pointer values convey
|
||||||
the notion of nonexistent objects.
|
the notion of inexistent objects.
|
||||||
|
|
||||||
This meaning of the null pointer value allowed pointers to became a ['de
|
This meaning of the null pointer value allowed pointers to became a ['de
|
||||||
facto] standard for handling optional objects because all you have to do
|
facto] standard for handling optional objects because all you have to do
|
||||||
to refer to a value which you don't really have is to use a null pointer
|
to refer to a value which you don't really have is to use a null pointer
|
||||||
value of the appropriate type. Pointers have been used for decades—from
|
value of the appropriate type. Pointers have been used for decades—from
|
||||||
the days of C APIs to modern C++ libraries—to ['refer] to optional (that is,
|
the days of C APIs to modern C++ libraries—to ['refer] to optional (that is,
|
||||||
possibly nonexistent) objects; particularly as optional arguments to a
|
possibly inexistent) objects; particularly as optional arguments to a
|
||||||
function, but also quite often as optional data members.
|
function, but also quite often as optional data members.
|
||||||
|
|
||||||
The possible presence of a null pointer value makes the operations that
|
The possible presence of a null pointer value makes the operations that
|
||||||
|
@ -1,30 +1,33 @@
|
|||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
||||||
<title>A note about optional<bool></title>
|
<title>A note about
|
||||||
|
optional<bool></title>
|
||||||
<link rel="stylesheet" href="../boostbook.css" type="text/css">
|
<link rel="stylesheet" href="../boostbook.css" type="text/css">
|
||||||
<meta name="generator" content="DocBook XSL Stylesheets V1.75.2">
|
<meta name="generator" content="DocBook XSL Stylesheets V1.70.1">
|
||||||
<link rel="home" href="../index.html" title="Chapter 1. Boost.Optional">
|
<link rel="start" href="../index.html" title="Chapter<EFBFBD>1.<2E>Boost.Optional">
|
||||||
<link rel="up" href="../index.html" title="Chapter 1. Boost.Optional">
|
<link rel="up" href="../index.html" title="Chapter<EFBFBD>1.<2E>Boost.Optional">
|
||||||
<link rel="prev" href="in_place_factories.html" title="In-Place Factories">
|
<link rel="prev" href="in_place_factories.html" title="In-Place Factories">
|
||||||
<link rel="next" href="exception_safety_guarantees.html" title="Exception Safety Guarantees">
|
<link rel="next" href="exception_safety_guarantees.html" title="Exception Safety
|
||||||
|
Guarantees">
|
||||||
</head>
|
</head>
|
||||||
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
||||||
<table cellpadding="2" width="100%"><tr>
|
<table cellpadding="2" width="100%"><tr>
|
||||||
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../boost.png"></td>
|
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../boost.png"></td>
|
||||||
<td align="center"><a href="../../../../../index.html">Home</a></td>
|
<td align="center"><a href="../../../../../index.htm">Home</a></td>
|
||||||
<td align="center"><a href="../../../../../libs/libraries.htm">Libraries</a></td>
|
<td align="center"><a href="../../../../libraries.htm">Libraries</a></td>
|
||||||
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
|
<td align="center"><a href="http://www.boost.org/people/people.htm">People</a></td>
|
||||||
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
|
<td align="center"><a href="http://www.boost.org/more/faq.htm">FAQ</a></td>
|
||||||
<td align="center"><a href="../../../../../more/index.htm">More</a></td>
|
<td align="center"><a href="../../../../../more/index.htm">More</a></td>
|
||||||
</tr></table>
|
</tr></table>
|
||||||
<hr>
|
<hr>
|
||||||
<div class="spirit-nav">
|
<div class="spirit-nav">
|
||||||
<a accesskey="p" href="in_place_factories.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><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="exception_safety_guarantees.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
|
<a accesskey="p" href="in_place_factories.html"><img src="../../../../../doc/html/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/html/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/html/images/home.png" alt="Home"></a><a accesskey="n" href="exception_safety_guarantees.html"><img src="../../../../../doc/html/images/next.png" alt="Next"></a>
|
||||||
</div>
|
</div>
|
||||||
<div class="section">
|
<div class="section" lang="en">
|
||||||
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
|
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
|
||||||
<a name="boost_optional.a_note_about_optional_bool_"></a><a class="link" href="a_note_about_optional_bool_.html" title="A note about optional<bool>">A note about
|
<a name="boost_optional.a_note_about_optional_bool_"></a><a href="a_note_about_optional_bool_.html" title="A note about
|
||||||
|
optional<bool>">A note about
|
||||||
optional<bool></a>
|
optional<bool></a>
|
||||||
</h2></div></div></div>
|
</h2></div></div></div>
|
||||||
<p>
|
<p>
|
||||||
@ -33,7 +36,7 @@
|
|||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
First, it is functionally similar to a tristate boolean (false,maybe,true)
|
First, it is functionally similar to a tristate boolean (false,maybe,true)
|
||||||
—such as <a href="../../../../../doc/html/tribool.html" target="_top">boost::tribool</a>—
|
—such as <a href="../../../../tribool/index.html" target="_top">boost::tribool</a>—
|
||||||
except that in a tristate boolean, the maybe state <span class="underline">represents
|
except that in a tristate boolean, the maybe state <span class="underline">represents
|
||||||
a valid value</span>, unlike the corresponding state of an uninitialized
|
a valid value</span>, unlike the corresponding state of an uninitialized
|
||||||
<code class="computeroutput"><span class="identifier">optional</span><span class="special"><</span><span class="keyword">bool</span><span class="special">></span></code>. It
|
<code class="computeroutput"><span class="identifier">optional</span><span class="special"><</span><span class="keyword">bool</span><span class="special">></span></code>. It
|
||||||
@ -49,7 +52,8 @@
|
|||||||
lead to subtle errors due to the implicit <code class="computeroutput"><span class="keyword">bool</span></code>
|
lead to subtle errors due to the implicit <code class="computeroutput"><span class="keyword">bool</span></code>
|
||||||
conversion:
|
conversion:
|
||||||
</p>
|
</p>
|
||||||
<pre class="programlisting"><span class="keyword">void</span> <span class="identifier">foo</span> <span class="special">(</span> <span class="keyword">bool</span> <span class="identifier">v</span> <span class="special">)</span> <span class="special">;</span>
|
<pre class="programlisting">
|
||||||
|
<span class="keyword">void</span> <span class="identifier">foo</span> <span class="special">(</span> <span class="keyword">bool</span> <span class="identifier">v</span> <span class="special">)</span> <span class="special">;</span>
|
||||||
<span class="keyword">void</span> <span class="identifier">bar</span><span class="special">()</span>
|
<span class="keyword">void</span> <span class="identifier">bar</span><span class="special">()</span>
|
||||||
<span class="special">{</span>
|
<span class="special">{</span>
|
||||||
<span class="identifier">optional</span><span class="special"><</span><span class="keyword">bool</span><span class="special">></span> <span class="identifier">v</span> <span class="special">=</span> <span class="keyword">try</span><span class="special">();</span>
|
<span class="identifier">optional</span><span class="special"><</span><span class="keyword">bool</span><span class="special">></span> <span class="identifier">v</span> <span class="special">=</span> <span class="keyword">try</span><span class="special">();</span>
|
||||||
@ -70,7 +74,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||||||
<td align="left"></td>
|
<td align="left"></td>
|
||||||
<td align="right"><div class="copyright-footer">Copyright © 2003-2007 Fernando Luis Cacciola Carballal<p>
|
<td align="right"><div class="copyright-footer">Copyright <EFBFBD> 2003 -2007 Fernando Luis Cacciola Carballal<p>
|
||||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||||
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
|
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
|
||||||
</p>
|
</p>
|
||||||
@ -78,7 +82,7 @@
|
|||||||
</tr></table>
|
</tr></table>
|
||||||
<hr>
|
<hr>
|
||||||
<div class="spirit-nav">
|
<div class="spirit-nav">
|
||||||
<a accesskey="p" href="in_place_factories.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><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="exception_safety_guarantees.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
|
<a accesskey="p" href="in_place_factories.html"><img src="../../../../../doc/html/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/html/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/html/images/home.png" alt="Home"></a><a accesskey="n" href="exception_safety_guarantees.html"><img src="../../../../../doc/html/images/next.png" alt="Next"></a>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
@ -1,117 +1,118 @@
|
|||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
||||||
<title>Acknowledgments</title>
|
<title>Acknowledgments</title>
|
||||||
<link rel="stylesheet" href="../boostbook.css" type="text/css">
|
<link rel="stylesheet" href="../boostbook.css" type="text/css">
|
||||||
<meta name="generator" content="DocBook XSL Stylesheets V1.75.2">
|
<meta name="generator" content="DocBook XSL Stylesheets V1.70.1">
|
||||||
<link rel="home" href="../index.html" title="Chapter 1. Boost.Optional">
|
<link rel="start" href="../index.html" title="Chapter<EFBFBD>1.<2E>Boost.Optional">
|
||||||
<link rel="up" href="../index.html" title="Chapter 1. Boost.Optional">
|
<link rel="up" href="../index.html" title="Chapter<EFBFBD>1.<2E>Boost.Optional">
|
||||||
<link rel="prev" href="dependencies_and_portability.html" title="Dependencies and Portability">
|
<link rel="prev" href="dependencies_and_portability.html" title="Dependencies
|
||||||
|
and Portability">
|
||||||
</head>
|
</head>
|
||||||
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
||||||
<table cellpadding="2" width="100%"><tr>
|
<table cellpadding="2" width="100%"><tr>
|
||||||
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../boost.png"></td>
|
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../boost.png"></td>
|
||||||
<td align="center"><a href="../../../../../index.html">Home</a></td>
|
<td align="center"><a href="../../../../../index.htm">Home</a></td>
|
||||||
<td align="center"><a href="../../../../../libs/libraries.htm">Libraries</a></td>
|
<td align="center"><a href="../../../../libraries.htm">Libraries</a></td>
|
||||||
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
|
<td align="center"><a href="http://www.boost.org/people/people.htm">People</a></td>
|
||||||
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
|
<td align="center"><a href="http://www.boost.org/more/faq.htm">FAQ</a></td>
|
||||||
<td align="center"><a href="../../../../../more/index.htm">More</a></td>
|
<td align="center"><a href="../../../../../more/index.htm">More</a></td>
|
||||||
</tr></table>
|
</tr></table>
|
||||||
<hr>
|
<hr>
|
||||||
<div class="spirit-nav">
|
<div class="spirit-nav">
|
||||||
<a accesskey="p" href="dependencies_and_portability.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><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="p" href="dependencies_and_portability.html"><img src="../../../../../doc/html/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/html/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/html/images/home.png" alt="Home"></a>
|
||||||
</div>
|
</div>
|
||||||
<div class="section">
|
<div class="section" lang="en">
|
||||||
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
|
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
|
||||||
<a name="boost_optional.acknowledgments"></a><a class="link" href="acknowledgments.html" title="Acknowledgments">Acknowledgments</a>
|
<a name="boost_optional.acknowledgments"></a><a href="acknowledgments.html" title="Acknowledgments">Acknowledgments</a>
|
||||||
</h2></div></div></div>
|
</h2></div></div></div>
|
||||||
<a name="boost_optional.acknowledgments.pre_formal_review"></a><h4>
|
<a name="boost_optional.acknowledgments.pre_formal_review"></a><h4>
|
||||||
<a name="boost_optional.acknowledgments.pre_formal_review-heading"></a>
|
<a name="id2645003"></a>
|
||||||
<a class="link" href="acknowledgments.html#boost_optional.acknowledgments.pre_formal_review">Pre-formal
|
<a href="acknowledgments.html#boost_optional.acknowledgments.pre_formal_review">Pre-formal
|
||||||
review</a>
|
review</a>
|
||||||
</h4>
|
</h4>
|
||||||
<div class="itemizedlist"><ul class="itemizedlist" type="disc">
|
<div class="itemizedlist"><ul type="disc">
|
||||||
<li class="listitem">
|
<li>
|
||||||
Peter Dimov suggested the name 'optional', and was the first to point out
|
Peter Dimov suggested the name 'optional', and was the first to point out
|
||||||
the need for aligned storage.
|
the need for aligned storage.
|
||||||
</li>
|
</li>
|
||||||
<li class="listitem">
|
<li>
|
||||||
Douglas Gregor developed 'type_with_alignment', and later Eric Friedman
|
Douglas Gregor developed 'type_with_alignment', and later Eric Friedman coded
|
||||||
coded 'aligned_storage', which are the core of the optional class implementation.
|
'aligned_storage', which are the core of the optional class implementation.
|
||||||
</li>
|
</li>
|
||||||
<li class="listitem">
|
<li>
|
||||||
Andrei Alexandrescu and Brian Parker also worked with aligned storage techniques
|
Andrei Alexandrescu and Brian Parker also worked with aligned storage techniques
|
||||||
and their work influenced the current implementation.
|
and their work influenced the current implementation.
|
||||||
</li>
|
</li>
|
||||||
<li class="listitem">
|
<li>
|
||||||
Gennadiy Rozental made extensive and important comments which shaped the
|
Gennadiy Rozental made extensive and important comments which shaped the
|
||||||
design.
|
design.
|
||||||
</li>
|
</li>
|
||||||
<li class="listitem">
|
<li>
|
||||||
Vesa Karvonen and Douglas Gregor made quite useful comparisons between
|
Vesa Karvonen and Douglas Gregor made quite useful comparisons between optional,
|
||||||
optional, variant and any; and made other relevant comments.
|
variant and any; and made other relevant comments.
|
||||||
</li>
|
</li>
|
||||||
<li class="listitem">
|
<li>
|
||||||
Douglas Gregor and Peter Dimov commented on comparisons and evaluation
|
Douglas Gregor and Peter Dimov commented on comparisons and evaluation in
|
||||||
in boolean contexts.
|
boolean contexts.
|
||||||
</li>
|
</li>
|
||||||
<li class="listitem">
|
<li>
|
||||||
Eric Friedman helped understand the issues involved with aligned storage,
|
Eric Friedman helped understand the issues involved with aligned storage,
|
||||||
move/copy operations and exception safety.
|
move/copy operations and exception safety.
|
||||||
</li>
|
</li>
|
||||||
<li class="listitem">
|
<li>
|
||||||
Many others have participated with useful comments: Aleksey Gurotov, Kevlin
|
Many others have participated with useful comments: Aleksey Gurotov, Kevlin
|
||||||
Henney, David Abrahams, and others I can't recall.
|
Henney, David Abrahams, and others I can't recall.
|
||||||
</li>
|
</li>
|
||||||
</ul></div>
|
</ul></div>
|
||||||
<a name="boost_optional.acknowledgments.post_formal_review"></a><h4>
|
<a name="boost_optional.acknowledgments.post_formal_review"></a><h4>
|
||||||
<a name="boost_optional.acknowledgments.post_formal_review-heading"></a>
|
<a name="id2645073"></a>
|
||||||
<a class="link" href="acknowledgments.html#boost_optional.acknowledgments.post_formal_review">Post-formal
|
<a href="acknowledgments.html#boost_optional.acknowledgments.post_formal_review">Post-formal
|
||||||
review</a>
|
review</a>
|
||||||
</h4>
|
</h4>
|
||||||
<div class="itemizedlist"><ul class="itemizedlist" type="disc">
|
<div class="itemizedlist"><ul type="disc">
|
||||||
<li class="listitem">
|
<li>
|
||||||
William Kempf carefully considered the originally proposed interface and
|
William Kempf carefully considered the originally proposed interface and
|
||||||
suggested the new interface which is currently used. He also started and
|
suggested the new interface which is currently used. He also started and
|
||||||
fueled the discussion about the analogy optional<>/smart pointer
|
fueled the discussion about the analogy optional<>/smart pointer and
|
||||||
and about relational operators.
|
about relational operators.
|
||||||
</li>
|
</li>
|
||||||
<li class="listitem">
|
<li>
|
||||||
Peter Dimov, Joel de Guzman, David Abrahams, Tanton Gibbs and Ian Hanson
|
Peter Dimov, Joel de Guzman, David Abrahams, Tanton Gibbs and Ian Hanson
|
||||||
focused on the relational semantics of optional (originally undefined);
|
focused on the relational semantics of optional (originally undefined); concluding
|
||||||
concluding with the fact that the pointer-like interface doesn't make it
|
with the fact that the pointer-like interface doesn't make it a pointer so
|
||||||
a pointer so it shall have deep relational operators.
|
it shall have deep relational operators.
|
||||||
</li>
|
</li>
|
||||||
<li class="listitem">
|
<li>
|
||||||
Augustus Saunders also explored the different relational semantics between
|
Augustus Saunders also explored the different relational semantics between
|
||||||
optional<> and a pointer and developed the OptionalPointee concept
|
optional<> and a pointer and developed the OptionalPointee concept
|
||||||
as an aid against potential conflicts on generic code.
|
as an aid against potential conflicts on generic code.
|
||||||
</li>
|
</li>
|
||||||
<li class="listitem">
|
<li>
|
||||||
Joel de Guzman noticed that optional<> can be seen as an API on top
|
Joel de Guzman noticed that optional<> can be seen as an API on top
|
||||||
of variant<T,nil_t>.
|
of variant<T,nil_t>.
|
||||||
</li>
|
</li>
|
||||||
<li class="listitem">
|
<li>
|
||||||
Dave Gomboc explained the meaning and usage of the Haskell analog to optional<>:
|
Dave Gomboc explained the meaning and usage of the Haskell analog to optional<>:
|
||||||
the Maybe type constructor (analogy originally pointed out by David Sankel).
|
the Maybe type constructor (analogy originally pointed out by David Sankel).
|
||||||
</li>
|
</li>
|
||||||
<li class="listitem">
|
<li>
|
||||||
Other comments were posted by Vincent Finn, Anthony Williams, Ed Brey,
|
Other comments were posted by Vincent Finn, Anthony Williams, Ed Brey, Rob
|
||||||
Rob Stewart, and others.
|
Stewart, and others.
|
||||||
</li>
|
</li>
|
||||||
<li class="listitem">
|
<li>
|
||||||
Joel de Guzman made the case for the support of references and helped with
|
Joel de Guzman made the case for the support of references and helped with
|
||||||
the proper semantics.
|
the proper semantics.
|
||||||
</li>
|
</li>
|
||||||
<li class="listitem">
|
<li>
|
||||||
Mat Marcus shown the virtues of a value-oriented interface, influencing
|
Mat Marcus shown the virtues of a value-oriented interface, influencing the
|
||||||
the current design, and contributed the idea of "none".
|
current design, and contributed the idea of "none".
|
||||||
</li>
|
</li>
|
||||||
</ul></div>
|
</ul></div>
|
||||||
</div>
|
</div>
|
||||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||||||
<td align="left"></td>
|
<td align="left"></td>
|
||||||
<td align="right"><div class="copyright-footer">Copyright © 2003-2007 Fernando Luis Cacciola Carballal<p>
|
<td align="right"><div class="copyright-footer">Copyright <EFBFBD> 2003 -2007 Fernando Luis Cacciola Carballal<p>
|
||||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||||
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
|
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
|
||||||
</p>
|
</p>
|
||||||
@ -119,7 +120,7 @@
|
|||||||
</tr></table>
|
</tr></table>
|
||||||
<hr>
|
<hr>
|
||||||
<div class="spirit-nav">
|
<div class="spirit-nav">
|
||||||
<a accesskey="p" href="dependencies_and_portability.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><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="p" href="dependencies_and_portability.html"><img src="../../../../../doc/html/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/html/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/html/images/home.png" alt="Home"></a>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
@ -1,30 +1,32 @@
|
|||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
||||||
<title>Dependencies and Portability</title>
|
<title>Dependencies
|
||||||
|
and Portability</title>
|
||||||
<link rel="stylesheet" href="../boostbook.css" type="text/css">
|
<link rel="stylesheet" href="../boostbook.css" type="text/css">
|
||||||
<meta name="generator" content="DocBook XSL Stylesheets V1.75.2">
|
<meta name="generator" content="DocBook XSL Stylesheets V1.70.1">
|
||||||
<link rel="home" href="../index.html" title="Chapter 1. Boost.Optional">
|
<link rel="start" href="../index.html" title="Chapter<EFBFBD>1.<2E>Boost.Optional">
|
||||||
<link rel="up" href="../index.html" title="Chapter 1. Boost.Optional">
|
<link rel="up" href="../index.html" title="Chapter<EFBFBD>1.<2E>Boost.Optional">
|
||||||
<link rel="prev" href="implementation_notes.html" title="Implementation Notes">
|
<link rel="prev" href="implementation_notes.html" title="Implementation Notes">
|
||||||
<link rel="next" href="acknowledgments.html" title="Acknowledgments">
|
<link rel="next" href="acknowledgments.html" title="Acknowledgments">
|
||||||
</head>
|
</head>
|
||||||
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
||||||
<table cellpadding="2" width="100%"><tr>
|
<table cellpadding="2" width="100%"><tr>
|
||||||
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../boost.png"></td>
|
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../boost.png"></td>
|
||||||
<td align="center"><a href="../../../../../index.html">Home</a></td>
|
<td align="center"><a href="../../../../../index.htm">Home</a></td>
|
||||||
<td align="center"><a href="../../../../../libs/libraries.htm">Libraries</a></td>
|
<td align="center"><a href="../../../../libraries.htm">Libraries</a></td>
|
||||||
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
|
<td align="center"><a href="http://www.boost.org/people/people.htm">People</a></td>
|
||||||
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
|
<td align="center"><a href="http://www.boost.org/more/faq.htm">FAQ</a></td>
|
||||||
<td align="center"><a href="../../../../../more/index.htm">More</a></td>
|
<td align="center"><a href="../../../../../more/index.htm">More</a></td>
|
||||||
</tr></table>
|
</tr></table>
|
||||||
<hr>
|
<hr>
|
||||||
<div class="spirit-nav">
|
<div class="spirit-nav">
|
||||||
<a accesskey="p" href="implementation_notes.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><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="acknowledgments.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
|
<a accesskey="p" href="implementation_notes.html"><img src="../../../../../doc/html/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/html/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/html/images/home.png" alt="Home"></a><a accesskey="n" href="acknowledgments.html"><img src="../../../../../doc/html/images/next.png" alt="Next"></a>
|
||||||
</div>
|
</div>
|
||||||
<div class="section">
|
<div class="section" lang="en">
|
||||||
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
|
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
|
||||||
<a name="boost_optional.dependencies_and_portability"></a><a class="link" href="dependencies_and_portability.html" title="Dependencies and Portability">Dependencies
|
<a name="boost_optional.dependencies_and_portability"></a><a href="dependencies_and_portability.html" title="Dependencies
|
||||||
|
and Portability">Dependencies
|
||||||
and Portability</a>
|
and Portability</a>
|
||||||
</h2></div></div></div>
|
</h2></div></div></div>
|
||||||
<p>
|
<p>
|
||||||
@ -34,7 +36,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||||||
<td align="left"></td>
|
<td align="left"></td>
|
||||||
<td align="right"><div class="copyright-footer">Copyright © 2003-2007 Fernando Luis Cacciola Carballal<p>
|
<td align="right"><div class="copyright-footer">Copyright <EFBFBD> 2003 -2007 Fernando Luis Cacciola Carballal<p>
|
||||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||||
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
|
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
|
||||||
</p>
|
</p>
|
||||||
@ -42,7 +44,7 @@
|
|||||||
</tr></table>
|
</tr></table>
|
||||||
<hr>
|
<hr>
|
||||||
<div class="spirit-nav">
|
<div class="spirit-nav">
|
||||||
<a accesskey="p" href="implementation_notes.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><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="acknowledgments.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
|
<a accesskey="p" href="implementation_notes.html"><img src="../../../../../doc/html/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/html/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/html/images/home.png" alt="Home"></a><a accesskey="n" href="acknowledgments.html"><img src="../../../../../doc/html/images/next.png" alt="Next"></a>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -1,39 +1,39 @@
|
|||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
||||||
<title>Development</title>
|
<title>Development</title>
|
||||||
<link rel="stylesheet" href="../boostbook.css" type="text/css">
|
<link rel="stylesheet" href="../boostbook.css" type="text/css">
|
||||||
<meta name="generator" content="DocBook XSL Stylesheets V1.75.2">
|
<meta name="generator" content="DocBook XSL Stylesheets V1.70.1">
|
||||||
<link rel="home" href="../index.html" title="Chapter 1. Boost.Optional">
|
<link rel="start" href="../index.html" title="Chapter<EFBFBD>1.<2E>Boost.Optional">
|
||||||
<link rel="up" href="../index.html" title="Chapter 1. Boost.Optional">
|
<link rel="up" href="../index.html" title="Chapter<EFBFBD>1.<2E>Boost.Optional">
|
||||||
<link rel="prev" href="../index.html" title="Chapter 1. Boost.Optional">
|
<link rel="prev" href="../index.html" title="Chapter<EFBFBD>1.<2E>Boost.Optional">
|
||||||
<link rel="next" href="synopsis.html" title="Synopsis">
|
<link rel="next" href="synopsis.html" title="Synopsis">
|
||||||
</head>
|
</head>
|
||||||
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
||||||
<table cellpadding="2" width="100%"><tr>
|
<table cellpadding="2" width="100%"><tr>
|
||||||
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../boost.png"></td>
|
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../boost.png"></td>
|
||||||
<td align="center"><a href="../../../../../index.html">Home</a></td>
|
<td align="center"><a href="../../../../../index.htm">Home</a></td>
|
||||||
<td align="center"><a href="../../../../../libs/libraries.htm">Libraries</a></td>
|
<td align="center"><a href="../../../../libraries.htm">Libraries</a></td>
|
||||||
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
|
<td align="center"><a href="http://www.boost.org/people/people.htm">People</a></td>
|
||||||
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
|
<td align="center"><a href="http://www.boost.org/more/faq.htm">FAQ</a></td>
|
||||||
<td align="center"><a href="../../../../../more/index.htm">More</a></td>
|
<td align="center"><a href="../../../../../more/index.htm">More</a></td>
|
||||||
</tr></table>
|
</tr></table>
|
||||||
<hr>
|
<hr>
|
||||||
<div class="spirit-nav">
|
<div class="spirit-nav">
|
||||||
<a accesskey="p" href="../index.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><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="synopsis.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
|
<a accesskey="p" href="../index.html"><img src="../../../../../doc/html/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/html/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/html/images/home.png" alt="Home"></a><a accesskey="n" href="synopsis.html"><img src="../../../../../doc/html/images/next.png" alt="Next"></a>
|
||||||
</div>
|
</div>
|
||||||
<div class="section">
|
<div class="section" lang="en">
|
||||||
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
|
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
|
||||||
<a name="boost_optional.development"></a><a class="link" href="development.html" title="Development">Development</a>
|
<a name="boost_optional.development"></a><a href="development.html" title="Development">Development</a>
|
||||||
</h2></div></div></div>
|
</h2></div></div></div>
|
||||||
<div class="toc"><dl>
|
<div class="toc"><dl>
|
||||||
<dt><span class="section"><a href="development.html#boost_optional.development.the_models">The models</a></span></dt>
|
<dt><span class="section"><a href="development.html#boost_optional.development.the_models">The models</a></span></dt>
|
||||||
<dt><span class="section"><a href="development.html#boost_optional.development.the_semantics">The semantics</a></span></dt>
|
<dt><span class="section"><a href="development.html#boost_optional.development.the_semantics">The semantics</a></span></dt>
|
||||||
<dt><span class="section"><a href="development.html#boost_optional.development.the_interface">The Interface</a></span></dt>
|
<dt><span class="section"><a href="development.html#boost_optional.development.the_interface">The Interface</a></span></dt>
|
||||||
</dl></div>
|
</dl></div>
|
||||||
<div class="section">
|
<div class="section" lang="en">
|
||||||
<div class="titlepage"><div><div><h3 class="title">
|
<div class="titlepage"><div><div><h3 class="title">
|
||||||
<a name="boost_optional.development.the_models"></a><a class="link" href="development.html#boost_optional.development.the_models" title="The models">The models</a>
|
<a name="boost_optional.development.the_models"></a><a href="development.html#boost_optional.development.the_models" title="The models">The models</a>
|
||||||
</h3></div></div></div>
|
</h3></div></div></div>
|
||||||
<p>
|
<p>
|
||||||
In C++, we can <span class="emphasis"><em>declare</em></span> an object (a variable) of type
|
In C++, we can <span class="emphasis"><em>declare</em></span> an object (a variable) of type
|
||||||
@ -96,7 +96,7 @@
|
|||||||
value of <code class="computeroutput"><span class="identifier">T</span></code> or nothing.
|
value of <code class="computeroutput"><span class="identifier">T</span></code> or nothing.
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
As of this writing I don't know of any precedent for a variable-size fixed-capacity
|
As of this writing I don't know of any precedence for a variable-size fixed-capacity
|
||||||
(of 1) stack-based container model for optional values, yet I believe this
|
(of 1) stack-based container model for optional values, yet I believe this
|
||||||
is the consequence of the lack of practical implementations of such a container
|
is the consequence of the lack of practical implementations of such a container
|
||||||
rather than an inherent shortcoming of the container model.
|
rather than an inherent shortcoming of the container model.
|
||||||
@ -110,67 +110,67 @@
|
|||||||
<p>
|
<p>
|
||||||
Discriminated-union:
|
Discriminated-union:
|
||||||
</p>
|
</p>
|
||||||
<div class="itemizedlist"><ul class="itemizedlist" type="disc">
|
<div class="itemizedlist"><ul type="disc">
|
||||||
<li class="listitem">
|
<li>
|
||||||
<span class="bold"><strong>deep-copy</strong></span> semantics: copies of the variant
|
<span class="bold"><strong>deep-copy</strong></span> semantics: copies of the variant
|
||||||
implies copies of the value.
|
implies copies of the value.
|
||||||
</li>
|
</li>
|
||||||
<li class="listitem">
|
<li>
|
||||||
<span class="bold"><strong>deep-relational</strong></span> semantics: comparisons
|
<span class="bold"><strong>deep-relational</strong></span> semantics: comparisons
|
||||||
between variants matches both current types and values
|
between variants matches both current types and values
|
||||||
</li>
|
</li>
|
||||||
<li class="listitem">
|
<li>
|
||||||
If the variant's current type is <code class="computeroutput"><span class="identifier">T</span></code>,
|
If the variant's current type is <code class="computeroutput"><span class="identifier">T</span></code>,
|
||||||
it is modeling an <span class="emphasis"><em>initialized</em></span> optional.
|
it is modeling an <span class="emphasis"><em>initialized</em></span> optional.
|
||||||
</li>
|
</li>
|
||||||
<li class="listitem">
|
<li>
|
||||||
If the variant's current type is not <code class="computeroutput"><span class="identifier">T</span></code>,
|
If the variant's current type is not <code class="computeroutput"><span class="identifier">T</span></code>,
|
||||||
it is modeling an <span class="emphasis"><em>uninitialized</em></span> optional.
|
it is modeling an <span class="emphasis"><em>uninitialized</em></span> optional.
|
||||||
</li>
|
</li>
|
||||||
<li class="listitem">
|
<li>
|
||||||
Testing if the variant's current type is <code class="computeroutput"><span class="identifier">T</span></code>
|
Testing if the variant's current type is <code class="computeroutput"><span class="identifier">T</span></code>
|
||||||
models testing if the optional is initialized
|
models testing if the optional is initialized
|
||||||
</li>
|
</li>
|
||||||
<li class="listitem">
|
<li>
|
||||||
Trying to extract a <code class="computeroutput"><span class="identifier">T</span></code>
|
Trying to extract a <code class="computeroutput"><span class="identifier">T</span></code> from
|
||||||
from a variant when its current type is not <code class="computeroutput"><span class="identifier">T</span></code>,
|
a variant when its current type is not <code class="computeroutput"><span class="identifier">T</span></code>,
|
||||||
models the undefined behavior of trying to access the value of an uninitialized
|
models the undefined behavior of trying to access the value of an uninitialized
|
||||||
optional
|
optional
|
||||||
</li>
|
</li>
|
||||||
</ul></div>
|
</ul></div>
|
||||||
<p>
|
<p>
|
||||||
Single-element container:
|
Single-element container:
|
||||||
</p>
|
</p>
|
||||||
<div class="itemizedlist"><ul class="itemizedlist" type="disc">
|
<div class="itemizedlist"><ul type="disc">
|
||||||
<li class="listitem">
|
<li>
|
||||||
<span class="bold"><strong>deep-copy</strong></span> semantics: copies of the container
|
<span class="bold"><strong>deep-copy</strong></span> semantics: copies of the container
|
||||||
implies copies of the value.
|
implies copies of the value.
|
||||||
</li>
|
</li>
|
||||||
<li class="listitem">
|
<li>
|
||||||
<span class="bold"><strong>deep-relational</strong></span> semantics: comparisons
|
<span class="bold"><strong>deep-relational</strong></span> semantics: comparisons
|
||||||
between containers compare container size and if match, contained value
|
between containers compare container size and if match, contained value
|
||||||
</li>
|
</li>
|
||||||
<li class="listitem">
|
<li>
|
||||||
If the container is not empty (contains an object of type <code class="computeroutput"><span class="identifier">T</span></code>), it is modeling an <span class="emphasis"><em>initialized</em></span>
|
If the container is not empty (contains an object of type <code class="computeroutput"><span class="identifier">T</span></code>), it is modeling an <span class="emphasis"><em>initialized</em></span>
|
||||||
optional.
|
optional.
|
||||||
</li>
|
</li>
|
||||||
<li class="listitem">
|
<li>
|
||||||
If the container is empty, it is modeling an <span class="emphasis"><em>uninitialized</em></span>
|
If the container is empty, it is modeling an <span class="emphasis"><em>uninitialized</em></span>
|
||||||
optional.
|
optional.
|
||||||
</li>
|
</li>
|
||||||
<li class="listitem">
|
<li>
|
||||||
Testing if the container is empty models testing if the optional is initialized
|
Testing if the container is empty models testing if the optional is initialized
|
||||||
</li>
|
</li>
|
||||||
<li class="listitem">
|
<li>
|
||||||
Trying to extract a <code class="computeroutput"><span class="identifier">T</span></code>
|
Trying to extract a <code class="computeroutput"><span class="identifier">T</span></code> from
|
||||||
from an empty container models the undefined behavior of trying to access
|
an empty container models the undefined behavior of trying to access the
|
||||||
the value of an uninitialized optional
|
value of an uninitialized optional
|
||||||
</li>
|
</li>
|
||||||
</ul></div>
|
</ul></div>
|
||||||
</div>
|
</div>
|
||||||
<div class="section">
|
<div class="section" lang="en">
|
||||||
<div class="titlepage"><div><div><h3 class="title">
|
<div class="titlepage"><div><div><h3 class="title">
|
||||||
<a name="boost_optional.development.the_semantics"></a><a class="link" href="development.html#boost_optional.development.the_semantics" title="The semantics">The semantics</a>
|
<a name="boost_optional.development.the_semantics"></a><a href="development.html#boost_optional.development.the_semantics" title="The semantics">The semantics</a>
|
||||||
</h3></div></div></div>
|
</h3></div></div></div>
|
||||||
<p>
|
<p>
|
||||||
Objects of type <code class="computeroutput"><span class="identifier">optional</span><span class="special"><</span><span class="identifier">T</span><span class="special">></span></code>
|
Objects of type <code class="computeroutput"><span class="identifier">optional</span><span class="special"><</span><span class="identifier">T</span><span class="special">></span></code>
|
||||||
@ -193,59 +193,58 @@
|
|||||||
We can draw from the purpose of <code class="computeroutput"><span class="identifier">optional</span><span class="special"><</span><span class="identifier">T</span><span class="special">></span></code>
|
We can draw from the purpose of <code class="computeroutput"><span class="identifier">optional</span><span class="special"><</span><span class="identifier">T</span><span class="special">></span></code>
|
||||||
the required basic semantics:
|
the required basic semantics:
|
||||||
</p>
|
</p>
|
||||||
<div class="itemizedlist"><ul class="itemizedlist" type="disc">
|
<div class="itemizedlist"><ul type="disc">
|
||||||
<li class="listitem">
|
<li>
|
||||||
<span class="bold"><strong>Default Construction:</strong></span> To introduce a
|
<span class="bold"><strong>Default Construction:</strong></span> To introduce a formally
|
||||||
formally uninitialized wrapped object.
|
uninitialized wrapped object.
|
||||||
</li>
|
</li>
|
||||||
<li class="listitem">
|
<li>
|
||||||
<span class="bold"><strong>Direct Value Construction via copy:</strong></span>
|
<span class="bold"><strong>Direct Value Construction via copy:</strong></span> To
|
||||||
To introduce a formally initialized wrapped object whose value is obtained
|
introduce a formally initialized wrapped object whose value is obtained
|
||||||
as a copy of some object.
|
as a copy of some object.
|
||||||
</li>
|
</li>
|
||||||
<li class="listitem">
|
<li>
|
||||||
<span class="bold"><strong>Deep Copy Construction:</strong></span> To obtain a
|
<span class="bold"><strong>Deep Copy Construction:</strong></span> To obtain a new
|
||||||
new yet equivalent wrapped object.
|
yet equivalent wrapped object.
|
||||||
</li>
|
</li>
|
||||||
<li class="listitem">
|
<li>
|
||||||
<span class="bold"><strong>Direct Value Assignment (upon initialized):</strong></span>
|
<span class="bold"><strong>Direct Value Assignment (upon initialized):</strong></span>
|
||||||
To assign a value to the wrapped object.
|
To assign a value to the wrapped object.
|
||||||
</li>
|
</li>
|
||||||
<li class="listitem">
|
<li>
|
||||||
<span class="bold"><strong>Direct Value Assignment (upon uninitialized):</strong></span>
|
<span class="bold"><strong>Direct Value Assignment (upon uninitialized):</strong></span>
|
||||||
To initialize the wrapped object with a value obtained as a copy of some
|
To initialize the wrapped object with a value obtained as a copy of some
|
||||||
object.
|
object.
|
||||||
</li>
|
</li>
|
||||||
<li class="listitem">
|
<li>
|
||||||
<span class="bold"><strong>Assignment (upon initialized):</strong></span> To assign
|
<span class="bold"><strong>Assignment (upon initialized):</strong></span> To assign
|
||||||
to the wrapped object the value of another wrapped object.
|
to the wrapped object the value of another wrapped object.
|
||||||
</li>
|
</li>
|
||||||
<li class="listitem">
|
<li>
|
||||||
<span class="bold"><strong>Assignment (upon uninitialized):</strong></span> To
|
<span class="bold"><strong>Assignment (upon uninitialized):</strong></span> To initialize
|
||||||
initialize the wrapped object with value of another wrapped object.
|
the wrapped object with value of another wrapped object.
|
||||||
</li>
|
</li>
|
||||||
<li class="listitem">
|
<li>
|
||||||
<span class="bold"><strong>Deep Relational Operations (when supported by the
|
<span class="bold"><strong>Deep Relational Operations (when supported by the
|
||||||
type T):</strong></span> To compare wrapped object values taking into account
|
type T):</strong></span> To compare wrapped object values taking into account
|
||||||
the presence of uninitialized states.
|
the presence of uninitialized states.
|
||||||
</li>
|
</li>
|
||||||
<li class="listitem">
|
<li>
|
||||||
<span class="bold"><strong>Value access:</strong></span> To unwrap the wrapped
|
<span class="bold"><strong>Value access:</strong></span> To unwrap the wrapped object.
|
||||||
object.
|
</li>
|
||||||
</li>
|
<li>
|
||||||
<li class="listitem">
|
<span class="bold"><strong>Initialization state query:</strong></span> To determine
|
||||||
<span class="bold"><strong>Initialization state query:</strong></span> To determine
|
if the object is formally initialized or not.
|
||||||
if the object is formally initialized or not.
|
</li>
|
||||||
</li>
|
<li>
|
||||||
<li class="listitem">
|
<span class="bold"><strong>Swap:</strong></span> To exchange wrapped objects. (with
|
||||||
<span class="bold"><strong>Swap:</strong></span> To exchange wrapped objects. (with
|
whatever exception safety guarantees are provided by <code class="computeroutput"><span class="identifier">T</span></code>'s
|
||||||
whatever exception safety guarantees are provided by <code class="computeroutput"><span class="identifier">T</span></code>'s
|
swap).
|
||||||
swap).
|
</li>
|
||||||
</li>
|
<li>
|
||||||
<li class="listitem">
|
<span class="bold"><strong>De-initialization:</strong></span> To release the wrapped
|
||||||
<span class="bold"><strong>De-initialization:</strong></span> To release the wrapped
|
object (if any) and leave the wrapper in the uninitialized state.
|
||||||
object (if any) and leave the wrapper in the uninitialized state.
|
</li>
|
||||||
</li>
|
|
||||||
</ul></div>
|
</ul></div>
|
||||||
<p>
|
<p>
|
||||||
Additional operations are useful, such as converting constructors and converting
|
Additional operations are useful, such as converting constructors and converting
|
||||||
@ -253,9 +252,9 @@
|
|||||||
via a pointer to the wrapped object or null.
|
via a pointer to the wrapped object or null.
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="section">
|
<div class="section" lang="en">
|
||||||
<div class="titlepage"><div><div><h3 class="title">
|
<div class="titlepage"><div><div><h3 class="title">
|
||||||
<a name="boost_optional.development.the_interface"></a><a class="link" href="development.html#boost_optional.development.the_interface" title="The Interface">The Interface</a>
|
<a name="boost_optional.development.the_interface"></a><a href="development.html#boost_optional.development.the_interface" title="The Interface">The Interface</a>
|
||||||
</h3></div></div></div>
|
</h3></div></div></div>
|
||||||
<p>
|
<p>
|
||||||
Since the purpose of optional is to allow us to use objects with a formal
|
Since the purpose of optional is to allow us to use objects with a formal
|
||||||
@ -293,8 +292,8 @@
|
|||||||
itself which are supported by a special interface.
|
itself which are supported by a special interface.
|
||||||
</p>
|
</p>
|
||||||
<a name="boost_optional.development.the_interface.lexically_hinted_value_access_in_the_presence_of_possibly_untitialized_optional_objects__the_operators___and___gt_"></a><h5>
|
<a name="boost_optional.development.the_interface.lexically_hinted_value_access_in_the_presence_of_possibly_untitialized_optional_objects__the_operators___and___gt_"></a><h5>
|
||||||
<a name="boost_optional.development.the_interface.lexically_hinted_value_access_in_the_presence_of_possibly_untitialized_optional_objects__the_operators___and___gt_-heading"></a>
|
<a name="id2615375"></a>
|
||||||
<a class="link" href="development.html#boost_optional.development.the_interface.lexically_hinted_value_access_in_the_presence_of_possibly_untitialized_optional_objects__the_operators___and___gt_">Lexically-hinted
|
<a href="development.html#boost_optional.development.the_interface.lexically_hinted_value_access_in_the_presence_of_possibly_untitialized_optional_objects__the_operators___and___gt_">Lexically-hinted
|
||||||
Value Access in the presence of possibly untitialized optional objects: The
|
Value Access in the presence of possibly untitialized optional objects: The
|
||||||
operators * and -></a>
|
operators * and -></a>
|
||||||
</h5>
|
</h5>
|
||||||
@ -302,7 +301,7 @@
|
|||||||
A relevant feature of a pointer is that it can have a <span class="bold"><strong>null
|
A relevant feature of a pointer is that it can have a <span class="bold"><strong>null
|
||||||
pointer value</strong></span>. This is a <span class="emphasis"><em>special</em></span> value which
|
pointer value</strong></span>. This is a <span class="emphasis"><em>special</em></span> value which
|
||||||
is used to indicate that the pointer is not referring to any object at all.
|
is used to indicate that the pointer is not referring to any object at all.
|
||||||
In other words, null pointer values convey the notion of nonexistent objects.
|
In other words, null pointer values convey the notion of inexistent objects.
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
This meaning of the null pointer value allowed pointers to became a <span class="emphasis"><em>de
|
This meaning of the null pointer value allowed pointers to became a <span class="emphasis"><em>de
|
||||||
@ -310,7 +309,7 @@
|
|||||||
to do to refer to a value which you don't really have is to use a null pointer
|
to do to refer to a value which you don't really have is to use a null pointer
|
||||||
value of the appropriate type. Pointers have been used for decades—from
|
value of the appropriate type. Pointers have been used for decades—from
|
||||||
the days of C APIs to modern C++ libraries—to <span class="emphasis"><em>refer</em></span>
|
the days of C APIs to modern C++ libraries—to <span class="emphasis"><em>refer</em></span>
|
||||||
to optional (that is, possibly nonexistent) objects; particularly as optional
|
to optional (that is, possibly inexistent) objects; particularly as optional
|
||||||
arguments to a function, but also quite often as optional data members.
|
arguments to a function, but also quite often as optional data members.
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
@ -358,8 +357,8 @@
|
|||||||
incarnated by pointers.
|
incarnated by pointers.
|
||||||
</p>
|
</p>
|
||||||
<a name="boost_optional.development.the_interface.optional_lt_t_gt__as_a_model_of_optionalpointee"></a><h5>
|
<a name="boost_optional.development.the_interface.optional_lt_t_gt__as_a_model_of_optionalpointee"></a><h5>
|
||||||
<a name="boost_optional.development.the_interface.optional_lt_t_gt__as_a_model_of_optionalpointee-heading"></a>
|
<a name="id2615714"></a>
|
||||||
<a class="link" href="development.html#boost_optional.development.the_interface.optional_lt_t_gt__as_a_model_of_optionalpointee">Optional<T>
|
<a href="development.html#boost_optional.development.the_interface.optional_lt_t_gt__as_a_model_of_optionalpointee">Optional<T>
|
||||||
as a model of OptionalPointee</a>
|
as a model of OptionalPointee</a>
|
||||||
</h5>
|
</h5>
|
||||||
<p>
|
<p>
|
||||||
@ -370,7 +369,7 @@
|
|||||||
</p>
|
</p>
|
||||||
<div class="warning"><table border="0" summary="Warning">
|
<div class="warning"><table border="0" summary="Warning">
|
||||||
<tr>
|
<tr>
|
||||||
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Warning]" src="../../../../../doc/src/images/warning.png"></td>
|
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Warning]" src="../../../../../doc/html/images/warning.png"></td>
|
||||||
<th align="left">Warning</th>
|
<th align="left">Warning</th>
|
||||||
</tr>
|
</tr>
|
||||||
<tr><td align="left" valign="top"><p>
|
<tr><td align="left" valign="top"><p>
|
||||||
@ -399,7 +398,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||||||
<td align="left"></td>
|
<td align="left"></td>
|
||||||
<td align="right"><div class="copyright-footer">Copyright © 2003-2007 Fernando Luis Cacciola Carballal<p>
|
<td align="right"><div class="copyright-footer">Copyright <EFBFBD> 2003 -2007 Fernando Luis Cacciola Carballal<p>
|
||||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||||
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
|
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
|
||||||
</p>
|
</p>
|
||||||
@ -407,7 +406,7 @@
|
|||||||
</tr></table>
|
</tr></table>
|
||||||
<hr>
|
<hr>
|
||||||
<div class="spirit-nav">
|
<div class="spirit-nav">
|
||||||
<a accesskey="p" href="../index.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><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="synopsis.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
|
<a accesskey="p" href="../index.html"><img src="../../../../../doc/html/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/html/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/html/images/home.png" alt="Home"></a><a accesskey="n" href="synopsis.html"><img src="../../../../../doc/html/images/next.png" alt="Next"></a>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
@ -1,30 +1,30 @@
|
|||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
||||||
<title>Examples</title>
|
<title>Examples</title>
|
||||||
<link rel="stylesheet" href="../boostbook.css" type="text/css">
|
<link rel="stylesheet" href="../boostbook.css" type="text/css">
|
||||||
<meta name="generator" content="DocBook XSL Stylesheets V1.75.2">
|
<meta name="generator" content="DocBook XSL Stylesheets V1.70.1">
|
||||||
<link rel="home" href="../index.html" title="Chapter 1. Boost.Optional">
|
<link rel="start" href="../index.html" title="Chapter<EFBFBD>1.<2E>Boost.Optional">
|
||||||
<link rel="up" href="../index.html" title="Chapter 1. Boost.Optional">
|
<link rel="up" href="../index.html" title="Chapter<EFBFBD>1.<2E>Boost.Optional">
|
||||||
<link rel="prev" href="detailed_semantics.html" title="Detailed Semantics">
|
<link rel="prev" href="detailed_semantics.html" title="Detailed Semantics">
|
||||||
<link rel="next" href="optional_references.html" title="Optional references">
|
<link rel="next" href="optional_references.html" title="Optional references">
|
||||||
</head>
|
</head>
|
||||||
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
||||||
<table cellpadding="2" width="100%"><tr>
|
<table cellpadding="2" width="100%"><tr>
|
||||||
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../boost.png"></td>
|
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../boost.png"></td>
|
||||||
<td align="center"><a href="../../../../../index.html">Home</a></td>
|
<td align="center"><a href="../../../../../index.htm">Home</a></td>
|
||||||
<td align="center"><a href="../../../../../libs/libraries.htm">Libraries</a></td>
|
<td align="center"><a href="../../../../libraries.htm">Libraries</a></td>
|
||||||
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
|
<td align="center"><a href="http://www.boost.org/people/people.htm">People</a></td>
|
||||||
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
|
<td align="center"><a href="http://www.boost.org/more/faq.htm">FAQ</a></td>
|
||||||
<td align="center"><a href="../../../../../more/index.htm">More</a></td>
|
<td align="center"><a href="../../../../../more/index.htm">More</a></td>
|
||||||
</tr></table>
|
</tr></table>
|
||||||
<hr>
|
<hr>
|
||||||
<div class="spirit-nav">
|
<div class="spirit-nav">
|
||||||
<a accesskey="p" href="detailed_semantics.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><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="optional_references.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
|
<a accesskey="p" href="detailed_semantics.html"><img src="../../../../../doc/html/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/html/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/html/images/home.png" alt="Home"></a><a accesskey="n" href="optional_references.html"><img src="../../../../../doc/html/images/next.png" alt="Next"></a>
|
||||||
</div>
|
</div>
|
||||||
<div class="section">
|
<div class="section" lang="en">
|
||||||
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
|
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
|
||||||
<a name="boost_optional.examples"></a><a class="link" href="examples.html" title="Examples">Examples</a>
|
<a name="boost_optional.examples"></a><a href="examples.html" title="Examples">Examples</a>
|
||||||
</h2></div></div></div>
|
</h2></div></div></div>
|
||||||
<div class="toc"><dl>
|
<div class="toc"><dl>
|
||||||
<dt><span class="section"><a href="examples.html#boost_optional.examples.optional_return_values">Optional
|
<dt><span class="section"><a href="examples.html#boost_optional.examples.optional_return_values">Optional
|
||||||
@ -36,12 +36,14 @@
|
|||||||
<dt><span class="section"><a href="examples.html#boost_optional.examples.bypassing_expensive_unnecessary_default_construction">Bypassing
|
<dt><span class="section"><a href="examples.html#boost_optional.examples.bypassing_expensive_unnecessary_default_construction">Bypassing
|
||||||
expensive unnecessary default construction</a></span></dt>
|
expensive unnecessary default construction</a></span></dt>
|
||||||
</dl></div>
|
</dl></div>
|
||||||
<div class="section">
|
<div class="section" lang="en">
|
||||||
<div class="titlepage"><div><div><h3 class="title">
|
<div class="titlepage"><div><div><h3 class="title">
|
||||||
<a name="boost_optional.examples.optional_return_values"></a><a class="link" href="examples.html#boost_optional.examples.optional_return_values" title="Optional return values">Optional
|
<a name="boost_optional.examples.optional_return_values"></a><a href="examples.html#boost_optional.examples.optional_return_values" title="Optional
|
||||||
|
return values">Optional
|
||||||
return values</a>
|
return values</a>
|
||||||
</h3></div></div></div>
|
</h3></div></div></div>
|
||||||
<pre class="programlisting"><span class="identifier">optional</span><span class="special"><</span><span class="keyword">char</span><span class="special">></span> <span class="identifier">get_async_input</span><span class="special">()</span>
|
<pre class="programlisting">
|
||||||
|
<span class="identifier">optional</span><span class="special"><</span><span class="keyword">char</span><span class="special">></span> <span class="identifier">get_async_input</span><span class="special">()</span>
|
||||||
<span class="special">{</span>
|
<span class="special">{</span>
|
||||||
<span class="keyword">if</span> <span class="special">(</span> <span class="special">!</span><span class="identifier">queue</span><span class="special">.</span><span class="identifier">empty</span><span class="special">()</span> <span class="special">)</span>
|
<span class="keyword">if</span> <span class="special">(</span> <span class="special">!</span><span class="identifier">queue</span><span class="special">.</span><span class="identifier">empty</span><span class="special">()</span> <span class="special">)</span>
|
||||||
<span class="keyword">return</span> <span class="identifier">optional</span><span class="special"><</span><span class="keyword">char</span><span class="special">>(</span><span class="identifier">queue</span><span class="special">.</span><span class="identifier">top</span><span class="special">());</span>
|
<span class="keyword">return</span> <span class="identifier">optional</span><span class="special"><</span><span class="keyword">char</span><span class="special">>(</span><span class="identifier">queue</span><span class="special">.</span><span class="identifier">top</span><span class="special">());</span>
|
||||||
@ -57,12 +59,14 @@
|
|||||||
<span class="special">}</span>
|
<span class="special">}</span>
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
</div>
|
||||||
<div class="section">
|
<div class="section" lang="en">
|
||||||
<div class="titlepage"><div><div><h3 class="title">
|
<div class="titlepage"><div><div><h3 class="title">
|
||||||
<a name="boost_optional.examples.optional_local_variables"></a><a class="link" href="examples.html#boost_optional.examples.optional_local_variables" title="Optional local variables">Optional
|
<a name="boost_optional.examples.optional_local_variables"></a><a href="examples.html#boost_optional.examples.optional_local_variables" title="Optional
|
||||||
|
local variables">Optional
|
||||||
local variables</a>
|
local variables</a>
|
||||||
</h3></div></div></div>
|
</h3></div></div></div>
|
||||||
<pre class="programlisting"><span class="identifier">optional</span><span class="special"><</span><span class="identifier">string</span><span class="special">></span> <span class="identifier">name</span> <span class="special">;</span>
|
<pre class="programlisting">
|
||||||
|
<span class="identifier">optional</span><span class="special"><</span><span class="identifier">string</span><span class="special">></span> <span class="identifier">name</span> <span class="special">;</span>
|
||||||
<span class="keyword">if</span> <span class="special">(</span> <span class="identifier">database</span><span class="special">.</span><span class="identifier">open</span><span class="special">()</span> <span class="special">)</span>
|
<span class="keyword">if</span> <span class="special">(</span> <span class="identifier">database</span><span class="special">.</span><span class="identifier">open</span><span class="special">()</span> <span class="special">)</span>
|
||||||
<span class="special">{</span>
|
<span class="special">{</span>
|
||||||
<span class="identifier">name</span><span class="special">.</span><span class="identifier">reset</span> <span class="special">(</span> <span class="identifier">database</span><span class="special">.</span><span class="identifier">lookup</span><span class="special">(</span><span class="identifier">employer_name</span><span class="special">)</span> <span class="special">)</span> <span class="special">;</span>
|
<span class="identifier">name</span><span class="special">.</span><span class="identifier">reset</span> <span class="special">(</span> <span class="identifier">database</span><span class="special">.</span><span class="identifier">lookup</span><span class="special">(</span><span class="identifier">employer_name</span><span class="special">)</span> <span class="special">)</span> <span class="special">;</span>
|
||||||
@ -78,12 +82,14 @@
|
|||||||
<span class="keyword">else</span> <span class="identifier">print</span><span class="special">(</span><span class="string">"employer's name not found!"</span><span class="special">);</span>
|
<span class="keyword">else</span> <span class="identifier">print</span><span class="special">(</span><span class="string">"employer's name not found!"</span><span class="special">);</span>
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
</div>
|
||||||
<div class="section">
|
<div class="section" lang="en">
|
||||||
<div class="titlepage"><div><div><h3 class="title">
|
<div class="titlepage"><div><div><h3 class="title">
|
||||||
<a name="boost_optional.examples.optional_data_members"></a><a class="link" href="examples.html#boost_optional.examples.optional_data_members" title="Optional data members">Optional
|
<a name="boost_optional.examples.optional_data_members"></a><a href="examples.html#boost_optional.examples.optional_data_members" title="Optional
|
||||||
|
data members">Optional
|
||||||
data members</a>
|
data members</a>
|
||||||
</h3></div></div></div>
|
</h3></div></div></div>
|
||||||
<pre class="programlisting"><span class="keyword">class</span> <span class="identifier">figure</span>
|
<pre class="programlisting">
|
||||||
|
<span class="keyword">class</span> <span class="identifier">figure</span>
|
||||||
<span class="special">{</span>
|
<span class="special">{</span>
|
||||||
<span class="keyword">public</span><span class="special">:</span>
|
<span class="keyword">public</span><span class="special">:</span>
|
||||||
|
|
||||||
@ -116,12 +122,14 @@
|
|||||||
<span class="special">};</span>
|
<span class="special">};</span>
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
</div>
|
||||||
<div class="section">
|
<div class="section" lang="en">
|
||||||
<div class="titlepage"><div><div><h3 class="title">
|
<div class="titlepage"><div><div><h3 class="title">
|
||||||
<a name="boost_optional.examples.bypassing_expensive_unnecessary_default_construction"></a><a class="link" href="examples.html#boost_optional.examples.bypassing_expensive_unnecessary_default_construction" title="Bypassing expensive unnecessary default construction">Bypassing
|
<a name="boost_optional.examples.bypassing_expensive_unnecessary_default_construction"></a><a href="examples.html#boost_optional.examples.bypassing_expensive_unnecessary_default_construction" title="Bypassing
|
||||||
|
expensive unnecessary default construction">Bypassing
|
||||||
expensive unnecessary default construction</a>
|
expensive unnecessary default construction</a>
|
||||||
</h3></div></div></div>
|
</h3></div></div></div>
|
||||||
<pre class="programlisting"><span class="keyword">class</span> <span class="identifier">ExpensiveCtor</span> <span class="special">{</span> <span class="special">...</span> <span class="special">}</span> <span class="special">;</span>
|
<pre class="programlisting">
|
||||||
|
<span class="keyword">class</span> <span class="identifier">ExpensiveCtor</span> <span class="special">{</span> <span class="special">...</span> <span class="special">}</span> <span class="special">;</span>
|
||||||
<span class="keyword">class</span> <span class="identifier">Fred</span>
|
<span class="keyword">class</span> <span class="identifier">Fred</span>
|
||||||
<span class="special">{</span>
|
<span class="special">{</span>
|
||||||
<span class="identifier">Fred</span><span class="special">()</span> <span class="special">:</span> <span class="identifier">mLargeVector</span><span class="special">(</span><span class="number">10000</span><span class="special">)</span> <span class="special">{}</span>
|
<span class="identifier">Fred</span><span class="special">()</span> <span class="special">:</span> <span class="identifier">mLargeVector</span><span class="special">(</span><span class="number">10000</span><span class="special">)</span> <span class="special">{}</span>
|
||||||
@ -133,7 +141,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||||||
<td align="left"></td>
|
<td align="left"></td>
|
||||||
<td align="right"><div class="copyright-footer">Copyright © 2003-2007 Fernando Luis Cacciola Carballal<p>
|
<td align="right"><div class="copyright-footer">Copyright <EFBFBD> 2003 -2007 Fernando Luis Cacciola Carballal<p>
|
||||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||||
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
|
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
|
||||||
</p>
|
</p>
|
||||||
@ -141,7 +149,7 @@
|
|||||||
</tr></table>
|
</tr></table>
|
||||||
<hr>
|
<hr>
|
||||||
<div class="spirit-nav">
|
<div class="spirit-nav">
|
||||||
<a accesskey="p" href="detailed_semantics.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><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="optional_references.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
|
<a accesskey="p" href="detailed_semantics.html"><img src="../../../../../doc/html/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/html/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/html/images/home.png" alt="Home"></a><a accesskey="n" href="optional_references.html"><img src="../../../../../doc/html/images/next.png" alt="Next"></a>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
@ -1,59 +1,54 @@
|
|||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
||||||
<title>Exception Safety Guarantees</title>
|
<title>Exception Safety
|
||||||
|
Guarantees</title>
|
||||||
<link rel="stylesheet" href="../boostbook.css" type="text/css">
|
<link rel="stylesheet" href="../boostbook.css" type="text/css">
|
||||||
<meta name="generator" content="DocBook XSL Stylesheets V1.75.2">
|
<meta name="generator" content="DocBook XSL Stylesheets V1.70.1">
|
||||||
<link rel="home" href="../index.html" title="Chapter 1. Boost.Optional">
|
<link rel="start" href="../index.html" title="Chapter<EFBFBD>1.<2E>Boost.Optional">
|
||||||
<link rel="up" href="../index.html" title="Chapter 1. Boost.Optional">
|
<link rel="up" href="../index.html" title="Chapter<EFBFBD>1.<2E>Boost.Optional">
|
||||||
<link rel="prev" href="a_note_about_optional_bool_.html" title="A note about optional<bool>">
|
<link rel="prev" href="a_note_about_optional_bool_.html" title="A note about
|
||||||
|
optional<bool>">
|
||||||
<link rel="next" href="type_requirements.html" title="Type requirements">
|
<link rel="next" href="type_requirements.html" title="Type requirements">
|
||||||
</head>
|
</head>
|
||||||
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
||||||
<table cellpadding="2" width="100%"><tr>
|
<table cellpadding="2" width="100%"><tr>
|
||||||
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../boost.png"></td>
|
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../boost.png"></td>
|
||||||
<td align="center"><a href="../../../../../index.html">Home</a></td>
|
<td align="center"><a href="../../../../../index.htm">Home</a></td>
|
||||||
<td align="center"><a href="../../../../../libs/libraries.htm">Libraries</a></td>
|
<td align="center"><a href="../../../../libraries.htm">Libraries</a></td>
|
||||||
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
|
<td align="center"><a href="http://www.boost.org/people/people.htm">People</a></td>
|
||||||
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
|
<td align="center"><a href="http://www.boost.org/more/faq.htm">FAQ</a></td>
|
||||||
<td align="center"><a href="../../../../../more/index.htm">More</a></td>
|
<td align="center"><a href="../../../../../more/index.htm">More</a></td>
|
||||||
</tr></table>
|
</tr></table>
|
||||||
<hr>
|
<hr>
|
||||||
<div class="spirit-nav">
|
<div class="spirit-nav">
|
||||||
<a accesskey="p" href="a_note_about_optional_bool_.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><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="type_requirements.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
|
<a accesskey="p" href="a_note_about_optional_bool_.html"><img src="../../../../../doc/html/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/html/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/html/images/home.png" alt="Home"></a><a accesskey="n" href="type_requirements.html"><img src="../../../../../doc/html/images/next.png" alt="Next"></a>
|
||||||
</div>
|
</div>
|
||||||
<div class="section">
|
<div class="section" lang="en">
|
||||||
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
|
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
|
||||||
<a name="boost_optional.exception_safety_guarantees"></a><a class="link" href="exception_safety_guarantees.html" title="Exception Safety Guarantees">Exception Safety
|
<a name="boost_optional.exception_safety_guarantees"></a><a href="exception_safety_guarantees.html" title="Exception Safety
|
||||||
|
Guarantees">Exception Safety
|
||||||
Guarantees</a>
|
Guarantees</a>
|
||||||
</h2></div></div></div>
|
</h2></div></div></div>
|
||||||
<p>
|
<p>
|
||||||
Because of the current implementation (see <a class="link" href="implementation_notes.html" title="Implementation Notes">Implementation
|
Because of the current implementation (see <a href="../index.html#optional_implementation_notes">Implementation
|
||||||
Notes</a>), all of the assignment methods:
|
Notes</a>), all of the assignment methods:
|
||||||
</p>
|
</p>
|
||||||
<div class="itemizedlist"><ul class="itemizedlist" type="disc">
|
<div class="itemizedlist"><ul type="disc">
|
||||||
<li class="listitem">
|
<li><code class="computeroutput"><span class="identifier">optional</span><span class="special"><</span><span class="identifier">T</span><span class="special">>::</span><span class="keyword">operator</span><span class="special">=</span> <span class="special">(</span> <span class="identifier">optional</span><span class="special"><</span><span class="identifier">T</span><span class="special">></span>
|
||||||
<code class="computeroutput"><span class="identifier">optional</span><span class="special"><</span><span class="identifier">T</span><span class="special">>::</span><span class="keyword">operator</span><span class="special">=</span> <span class="special">(</span> <span class="identifier">optional</span><span class="special"><</span><span class="identifier">T</span><span class="special">></span> <span class="keyword">const</span><span class="special">&</span> <span class="special">)</span></code>
|
<span class="keyword">const</span><span class="special">&</span>
|
||||||
</li>
|
<span class="special">)</span></code></li>
|
||||||
<li class="listitem">
|
<li><code class="computeroutput"><span class="identifier">optional</span><span class="special"><</span><span class="identifier">T</span><span class="special">>::</span><span class="keyword">operator</span><span class="special">=</span> <span class="special">(</span> <span class="identifier">T</span> <span class="keyword">const</span><span class="special">&</span> <span class="special">)</span></code></li>
|
||||||
<code class="computeroutput"><span class="identifier">optional</span><span class="special"><</span><span class="identifier">T</span><span class="special">>::</span><span class="keyword">operator</span><span class="special">=</span> <span class="special">(</span> <span class="identifier">T</span> <span class="keyword">const</span><span class="special">&</span> <span class="special">)</span></code>
|
<li><code class="computeroutput"><span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">U</span><span class="special">></span> <span class="identifier">optional</span><span class="special"><</span><span class="identifier">T</span><span class="special">>::</span><span class="keyword">operator</span><span class="special">=</span> <span class="special">(</span> <span class="identifier">optional</span><span class="special"><</span><span class="identifier">U</span><span class="special">></span>
|
||||||
</li>
|
<span class="keyword">const</span><span class="special">&</span>
|
||||||
<li class="listitem">
|
<span class="special">)</span></code></li>
|
||||||
<code class="computeroutput"><span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">U</span><span class="special">></span> <span class="identifier">optional</span><span class="special"><</span><span class="identifier">T</span><span class="special">>::</span><span class="keyword">operator</span><span class="special">=</span> <span class="special">(</span> <span class="identifier">optional</span><span class="special"><</span><span class="identifier">U</span><span class="special">></span> <span class="keyword">const</span><span class="special">&</span> <span class="special">)</span></code>
|
<li><code class="computeroutput"><span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">InPlaceFactory</span><span class="special">></span> <span class="identifier">optional</span><span class="special"><</span><span class="identifier">T</span><span class="special">>::</span><span class="keyword">operator</span><span class="special">=</span> <span class="special">(</span> <span class="identifier">InPlaceFactory</span>
|
||||||
</li>
|
<span class="keyword">const</span><span class="special">&</span>
|
||||||
<li class="listitem">
|
<span class="special">)</span></code></li>
|
||||||
<code class="computeroutput"><span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">InPlaceFactory</span><span class="special">></span> <span class="identifier">optional</span><span class="special"><</span><span class="identifier">T</span><span class="special">>::</span><span class="keyword">operator</span><span class="special">=</span> <span class="special">(</span> <span class="identifier">InPlaceFactory</span>
|
<li><code class="computeroutput"><span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">TypedInPlaceFactory</span><span class="special">></span> <span class="identifier">optional</span><span class="special"><</span><span class="identifier">T</span><span class="special">>::</span><span class="keyword">operator</span><span class="special">=</span> <span class="special">(</span> <span class="identifier">TypedInPlaceFactory</span>
|
||||||
<span class="keyword">const</span><span class="special">&</span>
|
<span class="keyword">const</span><span class="special">&</span>
|
||||||
<span class="special">)</span></code>
|
<span class="special">)</span> </code></li>
|
||||||
</li>
|
<li><code class="computeroutput"><span class="identifier">optional</span><span class="special"><</span><span class="identifier">T</span><span class="special">>:::</span><span class="identifier">reset</span> <span class="special">(</span> <span class="identifier">T</span> <span class="keyword">const</span><span class="special">&)</span></code></li>
|
||||||
<li class="listitem">
|
|
||||||
<code class="computeroutput"><span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">TypedInPlaceFactory</span><span class="special">></span> <span class="identifier">optional</span><span class="special"><</span><span class="identifier">T</span><span class="special">>::</span><span class="keyword">operator</span><span class="special">=</span> <span class="special">(</span> <span class="identifier">TypedInPlaceFactory</span>
|
|
||||||
<span class="keyword">const</span><span class="special">&</span>
|
|
||||||
<span class="special">)</span> </code>
|
|
||||||
</li>
|
|
||||||
<li class="listitem">
|
|
||||||
<code class="computeroutput"><span class="identifier">optional</span><span class="special"><</span><span class="identifier">T</span><span class="special">>:::</span><span class="identifier">reset</span> <span class="special">(</span> <span class="identifier">T</span> <span class="keyword">const</span><span class="special">&)</span></code>
|
|
||||||
</li>
|
|
||||||
</ul></div>
|
</ul></div>
|
||||||
<p>
|
<p>
|
||||||
Can only <span class="emphasis"><em>guarantee</em></span> the <span class="underline">basic
|
Can only <span class="emphasis"><em>guarantee</em></span> the <span class="underline">basic
|
||||||
@ -64,13 +59,9 @@
|
|||||||
<p>
|
<p>
|
||||||
On the other hand, the <span class="emphasis"><em>uninitializing</em></span> methods:
|
On the other hand, the <span class="emphasis"><em>uninitializing</em></span> methods:
|
||||||
</p>
|
</p>
|
||||||
<div class="itemizedlist"><ul class="itemizedlist" type="disc">
|
<div class="itemizedlist"><ul type="disc">
|
||||||
<li class="listitem">
|
<li><code class="computeroutput"><span class="identifier">optional</span><span class="special"><</span><span class="identifier">T</span><span class="special">>::</span><span class="keyword">operator</span><span class="special">=</span> <span class="special">(</span> <span class="identifier">detail</span><span class="special">::</span><span class="identifier">none_t</span> <span class="special">)</span></code></li>
|
||||||
<code class="computeroutput"><span class="identifier">optional</span><span class="special"><</span><span class="identifier">T</span><span class="special">>::</span><span class="keyword">operator</span><span class="special">=</span> <span class="special">(</span> <span class="identifier">detail</span><span class="special">::</span><span class="identifier">none_t</span> <span class="special">)</span></code>
|
<li><code class="computeroutput"><span class="identifier">optional</span><span class="special"><</span><span class="identifier">T</span><span class="special">>::</span><span class="identifier">reset</span><span class="special">()</span></code></li>
|
||||||
</li>
|
|
||||||
<li class="listitem">
|
|
||||||
<code class="computeroutput"><span class="identifier">optional</span><span class="special"><</span><span class="identifier">T</span><span class="special">>::</span><span class="identifier">reset</span><span class="special">()</span></code>
|
|
||||||
</li>
|
|
||||||
</ul></div>
|
</ul></div>
|
||||||
<p>
|
<p>
|
||||||
Provide the no-throw guarantee (assuming a no-throw <code class="computeroutput"><span class="identifier">T</span><span class="special">::~</span><span class="identifier">T</span><span class="special">()</span></code>)
|
Provide the no-throw guarantee (assuming a no-throw <code class="computeroutput"><span class="identifier">T</span><span class="special">::~</span><span class="identifier">T</span><span class="special">()</span></code>)
|
||||||
@ -84,7 +75,8 @@
|
|||||||
know that <code class="computeroutput"><span class="identifier">optional</span></code>'s assignment
|
know that <code class="computeroutput"><span class="identifier">optional</span></code>'s assignment
|
||||||
and reset has the same guarantees.
|
and reset has the same guarantees.
|
||||||
</p>
|
</p>
|
||||||
<pre class="programlisting"><span class="comment">//
|
<pre class="programlisting">
|
||||||
|
<span class="comment">//
|
||||||
</span><span class="comment">// Case 1: Exception thrown during assignment.
|
</span><span class="comment">// Case 1: Exception thrown during assignment.
|
||||||
</span><span class="comment">//
|
</span><span class="comment">//
|
||||||
</span><span class="identifier">T</span> <span class="identifier">v0</span><span class="special">(</span><span class="number">123</span><span class="special">);</span>
|
</span><span class="identifier">T</span> <span class="identifier">v0</span><span class="special">(</span><span class="number">123</span><span class="special">);</span>
|
||||||
@ -124,8 +116,8 @@
|
|||||||
<span class="special">}</span>
|
<span class="special">}</span>
|
||||||
</pre>
|
</pre>
|
||||||
<a name="boost_optional.exception_safety_guarantees.swap"></a><h4>
|
<a name="boost_optional.exception_safety_guarantees.swap"></a><h4>
|
||||||
<a name="boost_optional.exception_safety_guarantees.swap-heading"></a>
|
<a name="id2644478"></a>
|
||||||
<a class="link" href="exception_safety_guarantees.html#boost_optional.exception_safety_guarantees.swap">Swap</a>
|
<a href="exception_safety_guarantees.html#boost_optional.exception_safety_guarantees.swap">Swap</a>
|
||||||
</h4>
|
</h4>
|
||||||
<p>
|
<p>
|
||||||
<code class="computeroutput"><span class="keyword">void</span> <span class="identifier">swap</span><span class="special">(</span> <span class="identifier">optional</span><span class="special"><</span><span class="identifier">T</span><span class="special">>&,</span>
|
<code class="computeroutput"><span class="keyword">void</span> <span class="identifier">swap</span><span class="special">(</span> <span class="identifier">optional</span><span class="special"><</span><span class="identifier">T</span><span class="special">>&,</span>
|
||||||
@ -138,7 +130,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||||||
<td align="left"></td>
|
<td align="left"></td>
|
||||||
<td align="right"><div class="copyright-footer">Copyright © 2003-2007 Fernando Luis Cacciola Carballal<p>
|
<td align="right"><div class="copyright-footer">Copyright <EFBFBD> 2003 -2007 Fernando Luis Cacciola Carballal<p>
|
||||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||||
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
|
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
|
||||||
</p>
|
</p>
|
||||||
@ -146,7 +138,7 @@
|
|||||||
</tr></table>
|
</tr></table>
|
||||||
<hr>
|
<hr>
|
||||||
<div class="spirit-nav">
|
<div class="spirit-nav">
|
||||||
<a accesskey="p" href="a_note_about_optional_bool_.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><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="type_requirements.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
|
<a accesskey="p" href="a_note_about_optional_bool_.html"><img src="../../../../../doc/html/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/html/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/html/images/home.png" alt="Home"></a><a accesskey="n" href="type_requirements.html"><img src="../../../../../doc/html/images/next.png" alt="Next"></a>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
@ -1,30 +1,31 @@
|
|||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
||||||
<title>Implementation Notes</title>
|
<title>Implementation Notes</title>
|
||||||
<link rel="stylesheet" href="../boostbook.css" type="text/css">
|
<link rel="stylesheet" href="../boostbook.css" type="text/css">
|
||||||
<meta name="generator" content="DocBook XSL Stylesheets V1.75.2">
|
<meta name="generator" content="DocBook XSL Stylesheets V1.70.1">
|
||||||
<link rel="home" href="../index.html" title="Chapter 1. Boost.Optional">
|
<link rel="start" href="../index.html" title="Chapter<EFBFBD>1.<2E>Boost.Optional">
|
||||||
<link rel="up" href="../index.html" title="Chapter 1. Boost.Optional">
|
<link rel="up" href="../index.html" title="Chapter<EFBFBD>1.<2E>Boost.Optional">
|
||||||
<link rel="prev" href="type_requirements.html" title="Type requirements">
|
<link rel="prev" href="type_requirements.html" title="Type requirements">
|
||||||
<link rel="next" href="dependencies_and_portability.html" title="Dependencies and Portability">
|
<link rel="next" href="dependencies_and_portability.html" title="Dependencies
|
||||||
|
and Portability">
|
||||||
</head>
|
</head>
|
||||||
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
||||||
<table cellpadding="2" width="100%"><tr>
|
<table cellpadding="2" width="100%"><tr>
|
||||||
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../boost.png"></td>
|
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../boost.png"></td>
|
||||||
<td align="center"><a href="../../../../../index.html">Home</a></td>
|
<td align="center"><a href="../../../../../index.htm">Home</a></td>
|
||||||
<td align="center"><a href="../../../../../libs/libraries.htm">Libraries</a></td>
|
<td align="center"><a href="../../../../libraries.htm">Libraries</a></td>
|
||||||
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
|
<td align="center"><a href="http://www.boost.org/people/people.htm">People</a></td>
|
||||||
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
|
<td align="center"><a href="http://www.boost.org/more/faq.htm">FAQ</a></td>
|
||||||
<td align="center"><a href="../../../../../more/index.htm">More</a></td>
|
<td align="center"><a href="../../../../../more/index.htm">More</a></td>
|
||||||
</tr></table>
|
</tr></table>
|
||||||
<hr>
|
<hr>
|
||||||
<div class="spirit-nav">
|
<div class="spirit-nav">
|
||||||
<a accesskey="p" href="type_requirements.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><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="dependencies_and_portability.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
|
<a accesskey="p" href="type_requirements.html"><img src="../../../../../doc/html/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/html/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/html/images/home.png" alt="Home"></a><a accesskey="n" href="dependencies_and_portability.html"><img src="../../../../../doc/html/images/next.png" alt="Next"></a>
|
||||||
</div>
|
</div>
|
||||||
<div class="section">
|
<div class="section" lang="en">
|
||||||
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
|
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
|
||||||
<a name="boost_optional.implementation_notes"></a><a class="link" href="implementation_notes.html" title="Implementation Notes">Implementation Notes</a>
|
<a name="boost_optional.implementation_notes"></a><a href="implementation_notes.html" title="Implementation Notes">Implementation Notes</a>
|
||||||
</h2></div></div></div>
|
</h2></div></div></div>
|
||||||
<p>
|
<p>
|
||||||
<code class="computeroutput"><span class="identifier">optional</span><span class="special"><</span><span class="identifier">T</span><span class="special">></span></code> is
|
<code class="computeroutput"><span class="identifier">optional</span><span class="special"><</span><span class="identifier">T</span><span class="special">></span></code> is
|
||||||
@ -41,7 +42,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||||||
<td align="left"></td>
|
<td align="left"></td>
|
||||||
<td align="right"><div class="copyright-footer">Copyright © 2003-2007 Fernando Luis Cacciola Carballal<p>
|
<td align="right"><div class="copyright-footer">Copyright <EFBFBD> 2003 -2007 Fernando Luis Cacciola Carballal<p>
|
||||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||||
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
|
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
|
||||||
</p>
|
</p>
|
||||||
@ -49,7 +50,7 @@
|
|||||||
</tr></table>
|
</tr></table>
|
||||||
<hr>
|
<hr>
|
||||||
<div class="spirit-nav">
|
<div class="spirit-nav">
|
||||||
<a accesskey="p" href="type_requirements.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><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="dependencies_and_portability.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
|
<a accesskey="p" href="type_requirements.html"><img src="../../../../../doc/html/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/html/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/html/images/home.png" alt="Home"></a><a accesskey="n" href="dependencies_and_portability.html"><img src="../../../../../doc/html/images/next.png" alt="Next"></a>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
@ -1,30 +1,32 @@
|
|||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
||||||
<title>In-Place Factories</title>
|
<title>In-Place Factories</title>
|
||||||
<link rel="stylesheet" href="../boostbook.css" type="text/css">
|
<link rel="stylesheet" href="../boostbook.css" type="text/css">
|
||||||
<meta name="generator" content="DocBook XSL Stylesheets V1.75.2">
|
<meta name="generator" content="DocBook XSL Stylesheets V1.70.1">
|
||||||
<link rel="home" href="../index.html" title="Chapter 1. Boost.Optional">
|
<link rel="start" href="../index.html" title="Chapter<EFBFBD>1.<2E>Boost.Optional">
|
||||||
<link rel="up" href="../index.html" title="Chapter 1. Boost.Optional">
|
<link rel="up" href="../index.html" title="Chapter<EFBFBD>1.<2E>Boost.Optional">
|
||||||
<link rel="prev" href="rebinding_semantics_for_assignment_of_optional_references.html" title="Rebinding semantics for assignment of optional references">
|
<link rel="prev" href="rebinding_semantics_for_assignment_of_optional_references.html" title="Rebinding
|
||||||
<link rel="next" href="a_note_about_optional_bool_.html" title="A note about optional<bool>">
|
semantics for assignment of optional references">
|
||||||
|
<link rel="next" href="a_note_about_optional_bool_.html" title="A note about
|
||||||
|
optional<bool>">
|
||||||
</head>
|
</head>
|
||||||
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
||||||
<table cellpadding="2" width="100%"><tr>
|
<table cellpadding="2" width="100%"><tr>
|
||||||
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../boost.png"></td>
|
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../boost.png"></td>
|
||||||
<td align="center"><a href="../../../../../index.html">Home</a></td>
|
<td align="center"><a href="../../../../../index.htm">Home</a></td>
|
||||||
<td align="center"><a href="../../../../../libs/libraries.htm">Libraries</a></td>
|
<td align="center"><a href="../../../../libraries.htm">Libraries</a></td>
|
||||||
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
|
<td align="center"><a href="http://www.boost.org/people/people.htm">People</a></td>
|
||||||
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
|
<td align="center"><a href="http://www.boost.org/more/faq.htm">FAQ</a></td>
|
||||||
<td align="center"><a href="../../../../../more/index.htm">More</a></td>
|
<td align="center"><a href="../../../../../more/index.htm">More</a></td>
|
||||||
</tr></table>
|
</tr></table>
|
||||||
<hr>
|
<hr>
|
||||||
<div class="spirit-nav">
|
<div class="spirit-nav">
|
||||||
<a accesskey="p" href="rebinding_semantics_for_assignment_of_optional_references.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><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="a_note_about_optional_bool_.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
|
<a accesskey="p" href="rebinding_semantics_for_assignment_of_optional_references.html"><img src="../../../../../doc/html/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/html/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/html/images/home.png" alt="Home"></a><a accesskey="n" href="a_note_about_optional_bool_.html"><img src="../../../../../doc/html/images/next.png" alt="Next"></a>
|
||||||
</div>
|
</div>
|
||||||
<div class="section">
|
<div class="section" lang="en">
|
||||||
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
|
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
|
||||||
<a name="boost_optional.in_place_factories"></a><a class="link" href="in_place_factories.html" title="In-Place Factories">In-Place Factories</a>
|
<a name="boost_optional.in_place_factories"></a><a href="in_place_factories.html" title="In-Place Factories">In-Place Factories</a>
|
||||||
</h2></div></div></div>
|
</h2></div></div></div>
|
||||||
<p>
|
<p>
|
||||||
One of the typical problems with wrappers and containers is that their interfaces
|
One of the typical problems with wrappers and containers is that their interfaces
|
||||||
@ -34,7 +36,8 @@
|
|||||||
but also requires the existence of a fully constructed object, often temporary,
|
but also requires the existence of a fully constructed object, often temporary,
|
||||||
just to follow the copy from:
|
just to follow the copy from:
|
||||||
</p>
|
</p>
|
||||||
<pre class="programlisting"><span class="keyword">struct</span> <span class="identifier">X</span>
|
<pre class="programlisting">
|
||||||
|
<span class="keyword">struct</span> <span class="identifier">X</span>
|
||||||
<span class="special">{</span>
|
<span class="special">{</span>
|
||||||
<span class="identifier">X</span> <span class="special">(</span> <span class="keyword">int</span><span class="special">,</span> <span class="identifier">std</span><span class="special">:::</span><span class="identifier">string</span> <span class="special">)</span> <span class="special">;</span>
|
<span class="identifier">X</span> <span class="special">(</span> <span class="keyword">int</span><span class="special">,</span> <span class="identifier">std</span><span class="special">:::</span><span class="identifier">string</span> <span class="special">)</span> <span class="special">;</span>
|
||||||
<span class="special">}</span> <span class="special">;</span>
|
<span class="special">}</span> <span class="special">;</span>
|
||||||
@ -59,7 +62,8 @@
|
|||||||
object right in the container's storage. In this scheme, the user only needs
|
object right in the container's storage. In this scheme, the user only needs
|
||||||
to supply the arguments to the constructor to use in the wrapped object construction.
|
to supply the arguments to the constructor to use in the wrapped object construction.
|
||||||
</p>
|
</p>
|
||||||
<pre class="programlisting"><span class="keyword">class</span> <span class="identifier">W</span>
|
<pre class="programlisting">
|
||||||
|
<span class="keyword">class</span> <span class="identifier">W</span>
|
||||||
<span class="special">{</span>
|
<span class="special">{</span>
|
||||||
<span class="identifier">X</span> <span class="identifier">wrapped_</span> <span class="special">;</span>
|
<span class="identifier">X</span> <span class="identifier">wrapped_</span> <span class="special">;</span>
|
||||||
|
|
||||||
@ -92,7 +96,8 @@
|
|||||||
<p>
|
<p>
|
||||||
For example, one member of this family looks like:
|
For example, one member of this family looks like:
|
||||||
</p>
|
</p>
|
||||||
<pre class="programlisting"><span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">,</span><span class="keyword">class</span> <span class="identifier">A0</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">A1</span><span class="special">></span>
|
<pre class="programlisting">
|
||||||
|
<span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">,</span><span class="keyword">class</span> <span class="identifier">A0</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">A1</span><span class="special">></span>
|
||||||
<span class="keyword">class</span> <span class="identifier">TypedInPlaceFactory2</span>
|
<span class="keyword">class</span> <span class="identifier">TypedInPlaceFactory2</span>
|
||||||
<span class="special">{</span>
|
<span class="special">{</span>
|
||||||
<span class="identifier">A0</span> <span class="identifier">m_a0</span> <span class="special">;</span> <span class="identifier">A1</span> <span class="identifier">m_a1</span> <span class="special">;</span>
|
<span class="identifier">A0</span> <span class="identifier">m_a0</span> <span class="special">;</span> <span class="identifier">A1</span> <span class="identifier">m_a1</span> <span class="special">;</span>
|
||||||
@ -107,7 +112,8 @@
|
|||||||
<p>
|
<p>
|
||||||
A wrapper class aware of this can use it as:
|
A wrapper class aware of this can use it as:
|
||||||
</p>
|
</p>
|
||||||
<pre class="programlisting"><span class="keyword">class</span> <span class="identifier">W</span>
|
<pre class="programlisting">
|
||||||
|
<span class="keyword">class</span> <span class="identifier">W</span>
|
||||||
<span class="special">{</span>
|
<span class="special">{</span>
|
||||||
<span class="identifier">X</span> <span class="identifier">wrapped_</span> <span class="special">;</span>
|
<span class="identifier">X</span> <span class="identifier">wrapped_</span> <span class="special">;</span>
|
||||||
|
|
||||||
@ -121,22 +127,22 @@
|
|||||||
<span class="special">{</span>
|
<span class="special">{</span>
|
||||||
<span class="comment">// Wrapped object constructed in-place via a TypedInPlaceFactory.
|
<span class="comment">// Wrapped object constructed in-place via a TypedInPlaceFactory.
|
||||||
</span> <span class="comment">// No temporary created.
|
</span> <span class="comment">// No temporary created.
|
||||||
</span> <span class="identifier">W</span> <span class="special">(</span> <span class="identifier">TypedInPlaceFactory2</span><span class="special"><</span><span class="identifier">X</span><span class="special">,</span><span class="keyword">int</span><span class="special">,</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span><span class="special">>(</span><span class="number">123</span><span class="special">,</span><span class="string">"hello"</span><span class="special">))</span> <span class="special">;</span>
|
</span> <span class="identifier">W</span> <span class="special">(</span> <span class="identifier">TypedInPlaceFactory2</span><span class="special"><</span><span class="identifier">X</span><span class="special">,</span><span class="keyword">int</span><span class="special">,</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span><span class="special">&</span><span class="identifier">rt</span><span class="special">(</span><span class="number">123</span><span class="special">,</span><span class="string">"hello"</span><span class="special">))</span> <span class="special">;</span>
|
||||||
<span class="special">}</span>
|
<span class="special">}</span>
|
||||||
</pre>
|
</pre>
|
||||||
<p>
|
<p>
|
||||||
The factories are divided in two groups:
|
The factories are divided in two groups:
|
||||||
</p>
|
</p>
|
||||||
<div class="itemizedlist"><ul class="itemizedlist" type="disc">
|
<div class="itemizedlist"><ul type="disc">
|
||||||
<li class="listitem">
|
<li>
|
||||||
<span class="underline">TypedInPlaceFactories</span>: those which
|
<span class="underline">TypedInPlaceFactories</span>: those which
|
||||||
take the target type as a primary template parameter.
|
take the target type as a primary template parameter.
|
||||||
</li>
|
</li>
|
||||||
<li class="listitem">
|
<li>
|
||||||
<span class="underline">InPlaceFactories</span>: those with a template
|
<span class="underline">InPlaceFactories</span>: those with a template
|
||||||
<code class="computeroutput"><span class="identifier">construct</span><span class="special">(</span><span class="keyword">void</span><span class="special">*)</span></code> member
|
<code class="computeroutput"><span class="identifier">construct</span><span class="special">(</span><span class="keyword">void</span><span class="special">*)</span></code> member
|
||||||
function taking the target type.
|
function taking the target type.
|
||||||
</li>
|
</li>
|
||||||
</ul></div>
|
</ul></div>
|
||||||
<p>
|
<p>
|
||||||
Within each group, all the family members differ only in the number of parameters
|
Within each group, all the family members differ only in the number of parameters
|
||||||
@ -146,7 +152,8 @@
|
|||||||
This library provides an overloaded set of helper template functions to construct
|
This library provides an overloaded set of helper template functions to construct
|
||||||
these factories without requiring unnecessary template parameters:
|
these factories without requiring unnecessary template parameters:
|
||||||
</p>
|
</p>
|
||||||
<pre class="programlisting"><span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">A0</span><span class="special">,...,</span><span class="keyword">class</span> <span class="identifier">AN</span><span class="special">></span>
|
<pre class="programlisting">
|
||||||
|
<span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">A0</span><span class="special">,...,</span><span class="keyword">class</span> <span class="identifier">AN</span><span class="special">></span>
|
||||||
<span class="identifier">InPlaceFactoryN</span> <span class="special"><</span><span class="identifier">A0</span><span class="special">,...,</span><span class="identifier">AN</span><span class="special">></span> <span class="identifier">in_place</span> <span class="special">(</span> <span class="identifier">A0</span> <span class="keyword">const</span><span class="special">&</span> <span class="identifier">a0</span><span class="special">,</span> <span class="special">...,</span> <span class="identifier">AN</span> <span class="keyword">const</span><span class="special">&</span> <span class="identifier">aN</span><span class="special">)</span> <span class="special">;</span>
|
<span class="identifier">InPlaceFactoryN</span> <span class="special"><</span><span class="identifier">A0</span><span class="special">,...,</span><span class="identifier">AN</span><span class="special">></span> <span class="identifier">in_place</span> <span class="special">(</span> <span class="identifier">A0</span> <span class="keyword">const</span><span class="special">&</span> <span class="identifier">a0</span><span class="special">,</span> <span class="special">...,</span> <span class="identifier">AN</span> <span class="keyword">const</span><span class="special">&</span> <span class="identifier">aN</span><span class="special">)</span> <span class="special">;</span>
|
||||||
|
|
||||||
<span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">,</span><span class="keyword">class</span> <span class="identifier">A0</span><span class="special">,...,</span><span class="keyword">class</span> <span class="identifier">AN</span><span class="special">></span>
|
<span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">,</span><span class="keyword">class</span> <span class="identifier">A0</span><span class="special">,...,</span><span class="keyword">class</span> <span class="identifier">AN</span><span class="special">></span>
|
||||||
@ -155,7 +162,8 @@
|
|||||||
<p>
|
<p>
|
||||||
In-place factories can be used generically by the wrapper and user as follows:
|
In-place factories can be used generically by the wrapper and user as follows:
|
||||||
</p>
|
</p>
|
||||||
<pre class="programlisting"><span class="keyword">class</span> <span class="identifier">W</span>
|
<pre class="programlisting">
|
||||||
|
<span class="keyword">class</span> <span class="identifier">W</span>
|
||||||
<span class="special">{</span>
|
<span class="special">{</span>
|
||||||
<span class="identifier">X</span> <span class="identifier">wrapped_</span> <span class="special">;</span>
|
<span class="identifier">X</span> <span class="identifier">wrapped_</span> <span class="special">;</span>
|
||||||
|
|
||||||
@ -182,7 +190,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||||||
<td align="left"></td>
|
<td align="left"></td>
|
||||||
<td align="right"><div class="copyright-footer">Copyright © 2003-2007 Fernando Luis Cacciola Carballal<p>
|
<td align="right"><div class="copyright-footer">Copyright <EFBFBD> 2003 -2007 Fernando Luis Cacciola Carballal<p>
|
||||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||||
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
|
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
|
||||||
</p>
|
</p>
|
||||||
@ -190,7 +198,7 @@
|
|||||||
</tr></table>
|
</tr></table>
|
||||||
<hr>
|
<hr>
|
||||||
<div class="spirit-nav">
|
<div class="spirit-nav">
|
||||||
<a accesskey="p" href="rebinding_semantics_for_assignment_of_optional_references.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><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="a_note_about_optional_bool_.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
|
<a accesskey="p" href="rebinding_semantics_for_assignment_of_optional_references.html"><img src="../../../../../doc/html/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/html/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/html/images/home.png" alt="Home"></a><a accesskey="n" href="a_note_about_optional_bool_.html"><img src="../../../../../doc/html/images/next.png" alt="Next"></a>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
@ -1,30 +1,31 @@
|
|||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
||||||
<title>Optional references</title>
|
<title>Optional references</title>
|
||||||
<link rel="stylesheet" href="../boostbook.css" type="text/css">
|
<link rel="stylesheet" href="../boostbook.css" type="text/css">
|
||||||
<meta name="generator" content="DocBook XSL Stylesheets V1.75.2">
|
<meta name="generator" content="DocBook XSL Stylesheets V1.70.1">
|
||||||
<link rel="home" href="../index.html" title="Chapter 1. Boost.Optional">
|
<link rel="start" href="../index.html" title="Chapter<EFBFBD>1.<2E>Boost.Optional">
|
||||||
<link rel="up" href="../index.html" title="Chapter 1. Boost.Optional">
|
<link rel="up" href="../index.html" title="Chapter<EFBFBD>1.<2E>Boost.Optional">
|
||||||
<link rel="prev" href="examples.html" title="Examples">
|
<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">
|
<link rel="next" href="rebinding_semantics_for_assignment_of_optional_references.html" title="Rebinding
|
||||||
|
semantics for assignment of optional references">
|
||||||
</head>
|
</head>
|
||||||
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
||||||
<table cellpadding="2" width="100%"><tr>
|
<table cellpadding="2" width="100%"><tr>
|
||||||
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../boost.png"></td>
|
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../boost.png"></td>
|
||||||
<td align="center"><a href="../../../../../index.html">Home</a></td>
|
<td align="center"><a href="../../../../../index.htm">Home</a></td>
|
||||||
<td align="center"><a href="../../../../../libs/libraries.htm">Libraries</a></td>
|
<td align="center"><a href="../../../../libraries.htm">Libraries</a></td>
|
||||||
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
|
<td align="center"><a href="http://www.boost.org/people/people.htm">People</a></td>
|
||||||
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
|
<td align="center"><a href="http://www.boost.org/more/faq.htm">FAQ</a></td>
|
||||||
<td align="center"><a href="../../../../../more/index.htm">More</a></td>
|
<td align="center"><a href="../../../../../more/index.htm">More</a></td>
|
||||||
</tr></table>
|
</tr></table>
|
||||||
<hr>
|
<hr>
|
||||||
<div class="spirit-nav">
|
<div class="spirit-nav">
|
||||||
<a accesskey="p" href="examples.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><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="rebinding_semantics_for_assignment_of_optional_references.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
|
<a accesskey="p" href="examples.html"><img src="../../../../../doc/html/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/html/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/html/images/home.png" alt="Home"></a><a accesskey="n" href="rebinding_semantics_for_assignment_of_optional_references.html"><img src="../../../../../doc/html/images/next.png" alt="Next"></a>
|
||||||
</div>
|
</div>
|
||||||
<div class="section">
|
<div class="section" lang="en">
|
||||||
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
|
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
|
||||||
<a name="boost_optional.optional_references"></a><a class="link" href="optional_references.html" title="Optional references">Optional references</a>
|
<a name="boost_optional.optional_references"></a><a href="optional_references.html" title="Optional references">Optional references</a>
|
||||||
</h2></div></div></div>
|
</h2></div></div></div>
|
||||||
<p>
|
<p>
|
||||||
This library allows the template parameter <code class="computeroutput"><span class="identifier">T</span></code>
|
This library allows the template parameter <code class="computeroutput"><span class="identifier">T</span></code>
|
||||||
@ -35,43 +36,43 @@
|
|||||||
However, since references are not real objects some restrictions apply and
|
However, since references are not real objects some restrictions apply and
|
||||||
some operations are not available in this case:
|
some operations are not available in this case:
|
||||||
</p>
|
</p>
|
||||||
<div class="itemizedlist"><ul class="itemizedlist" type="disc">
|
<div class="itemizedlist"><ul type="disc">
|
||||||
<li class="listitem">
|
<li>
|
||||||
Converting constructors
|
Converting constructors
|
||||||
</li>
|
</li>
|
||||||
<li class="listitem">
|
<li>
|
||||||
Converting assignment
|
Converting assignment
|
||||||
</li>
|
</li>
|
||||||
<li class="listitem">
|
<li>
|
||||||
InPlace construction
|
InPlace construction
|
||||||
</li>
|
</li>
|
||||||
<li class="listitem">
|
<li>
|
||||||
InPlace assignment
|
InPlace assignment
|
||||||
</li>
|
</li>
|
||||||
<li class="listitem">
|
<li>
|
||||||
Value-access via pointer
|
Value-access via pointer
|
||||||
</li>
|
</li>
|
||||||
</ul></div>
|
</ul></div>
|
||||||
<p>
|
<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>
|
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
|
treats it wrapped pseudo-object much as a real value, a true real reference
|
||||||
is stored so aliasing will ocurr:
|
is stored so aliasing will ocurr:
|
||||||
</p>
|
</p>
|
||||||
<div class="itemizedlist"><ul class="itemizedlist" type="disc">
|
<div class="itemizedlist"><ul type="disc">
|
||||||
<li class="listitem">
|
<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>
|
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
|
will copy the references but all these references will nonetheless reefer
|
||||||
to the same object.
|
to the same object.
|
||||||
</li>
|
</li>
|
||||||
<li class="listitem">
|
<li>
|
||||||
Value-access will actually provide access to the referenced object rather
|
Value-access will actually provide access to the referenced object rather
|
||||||
than the reference itself.
|
than the reference itself.
|
||||||
</li>
|
</li>
|
||||||
</ul></div>
|
</ul></div>
|
||||||
</div>
|
</div>
|
||||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||||||
<td align="left"></td>
|
<td align="left"></td>
|
||||||
<td align="right"><div class="copyright-footer">Copyright © 2003-2007 Fernando Luis Cacciola Carballal<p>
|
<td align="right"><div class="copyright-footer">Copyright <EFBFBD> 2003 -2007 Fernando Luis Cacciola Carballal<p>
|
||||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||||
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
|
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
|
||||||
</p>
|
</p>
|
||||||
@ -79,7 +80,7 @@
|
|||||||
</tr></table>
|
</tr></table>
|
||||||
<hr>
|
<hr>
|
||||||
<div class="spirit-nav">
|
<div class="spirit-nav">
|
||||||
<a accesskey="p" href="examples.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><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="rebinding_semantics_for_assignment_of_optional_references.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
|
<a accesskey="p" href="examples.html"><img src="../../../../../doc/html/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/html/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/html/images/home.png" alt="Home"></a><a accesskey="n" href="rebinding_semantics_for_assignment_of_optional_references.html"><img src="../../../../../doc/html/images/next.png" alt="Next"></a>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
@ -1,30 +1,32 @@
|
|||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
||||||
<title>Rebinding semantics for assignment of optional references</title>
|
<title>Rebinding
|
||||||
|
semantics for assignment of optional references</title>
|
||||||
<link rel="stylesheet" href="../boostbook.css" type="text/css">
|
<link rel="stylesheet" href="../boostbook.css" type="text/css">
|
||||||
<meta name="generator" content="DocBook XSL Stylesheets V1.75.2">
|
<meta name="generator" content="DocBook XSL Stylesheets V1.70.1">
|
||||||
<link rel="home" href="../index.html" title="Chapter 1. Boost.Optional">
|
<link rel="start" href="../index.html" title="Chapter<EFBFBD>1.<2E>Boost.Optional">
|
||||||
<link rel="up" href="../index.html" title="Chapter 1. Boost.Optional">
|
<link rel="up" href="../index.html" title="Chapter<EFBFBD>1.<2E>Boost.Optional">
|
||||||
<link rel="prev" href="optional_references.html" title="Optional references">
|
<link rel="prev" href="optional_references.html" title="Optional references">
|
||||||
<link rel="next" href="in_place_factories.html" title="In-Place Factories">
|
<link rel="next" href="in_place_factories.html" title="In-Place Factories">
|
||||||
</head>
|
</head>
|
||||||
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
||||||
<table cellpadding="2" width="100%"><tr>
|
<table cellpadding="2" width="100%"><tr>
|
||||||
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../boost.png"></td>
|
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../boost.png"></td>
|
||||||
<td align="center"><a href="../../../../../index.html">Home</a></td>
|
<td align="center"><a href="../../../../../index.htm">Home</a></td>
|
||||||
<td align="center"><a href="../../../../../libs/libraries.htm">Libraries</a></td>
|
<td align="center"><a href="../../../../libraries.htm">Libraries</a></td>
|
||||||
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
|
<td align="center"><a href="http://www.boost.org/people/people.htm">People</a></td>
|
||||||
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
|
<td align="center"><a href="http://www.boost.org/more/faq.htm">FAQ</a></td>
|
||||||
<td align="center"><a href="../../../../../more/index.htm">More</a></td>
|
<td align="center"><a href="../../../../../more/index.htm">More</a></td>
|
||||||
</tr></table>
|
</tr></table>
|
||||||
<hr>
|
<hr>
|
||||||
<div class="spirit-nav">
|
<div class="spirit-nav">
|
||||||
<a accesskey="p" href="optional_references.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><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="in_place_factories.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
|
<a accesskey="p" href="optional_references.html"><img src="../../../../../doc/html/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/html/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/html/images/home.png" alt="Home"></a><a accesskey="n" href="in_place_factories.html"><img src="../../../../../doc/html/images/next.png" alt="Next"></a>
|
||||||
</div>
|
</div>
|
||||||
<div class="section">
|
<div class="section" lang="en">
|
||||||
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
|
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
|
||||||
<a name="boost_optional.rebinding_semantics_for_assignment_of_optional_references"></a><a class="link" href="rebinding_semantics_for_assignment_of_optional_references.html" title="Rebinding semantics for assignment of optional references">Rebinding
|
<a name="boost_optional.rebinding_semantics_for_assignment_of_optional_references"></a><a href="rebinding_semantics_for_assignment_of_optional_references.html" title="Rebinding
|
||||||
|
semantics for assignment of optional references">Rebinding
|
||||||
semantics for assignment of optional references</a>
|
semantics for assignment of optional references</a>
|
||||||
</h2></div></div></div>
|
</h2></div></div></div>
|
||||||
<p>
|
<p>
|
||||||
@ -32,7 +34,8 @@
|
|||||||
the effect is to bind (for the first time) to the object. Clearly, there is
|
the effect is to bind (for the first time) to the object. Clearly, there is
|
||||||
no other choice.
|
no other choice.
|
||||||
</p>
|
</p>
|
||||||
<pre class="programlisting"><span class="keyword">int</span> <span class="identifier">x</span> <span class="special">=</span> <span class="number">1</span> <span class="special">;</span>
|
<pre class="programlisting">
|
||||||
|
<span class="keyword">int</span> <span class="identifier">x</span> <span class="special">=</span> <span class="number">1</span> <span class="special">;</span>
|
||||||
<span class="keyword">int</span><span class="special">&</span> <span class="identifier">rx</span> <span class="special">=</span> <span class="identifier">x</span> <span class="special">;</span>
|
<span class="keyword">int</span><span class="special">&</span> <span class="identifier">rx</span> <span class="special">=</span> <span class="identifier">x</span> <span class="special">;</span>
|
||||||
<span class="identifier">optional</span><span class="special"><</span><span class="keyword">int</span><span class="special">&></span> <span class="identifier">ora</span> <span class="special">;</span>
|
<span class="identifier">optional</span><span class="special"><</span><span class="keyword">int</span><span class="special">&></span> <span class="identifier">ora</span> <span class="special">;</span>
|
||||||
<span class="identifier">optional</span><span class="special"><</span><span class="keyword">int</span><span class="special">&></span> <span class="identifier">orb</span><span class="special">(</span><span class="identifier">x</span><span class="special">)</span> <span class="special">;</span>
|
<span class="identifier">optional</span><span class="special"><</span><span class="keyword">int</span><span class="special">&></span> <span class="identifier">orb</span><span class="special">(</span><span class="identifier">x</span><span class="special">)</span> <span class="special">;</span>
|
||||||
@ -42,9 +45,10 @@
|
|||||||
</pre>
|
</pre>
|
||||||
<p>
|
<p>
|
||||||
If you assign to a bare C++ reference, the assignment is forwarded to the referenced
|
If you assign to a bare C++ reference, the assignment is forwarded to the referenced
|
||||||
object; its value changes but the reference is never rebound.
|
object; it's value changes but the reference is never rebound.
|
||||||
</p>
|
</p>
|
||||||
<pre class="programlisting"><span class="keyword">int</span> <span class="identifier">a</span> <span class="special">=</span> <span class="number">1</span> <span class="special">;</span>
|
<pre class="programlisting">
|
||||||
|
<span class="keyword">int</span> <span class="identifier">a</span> <span class="special">=</span> <span class="number">1</span> <span class="special">;</span>
|
||||||
<span class="keyword">int</span><span class="special">&</span> <span class="identifier">ra</span> <span class="special">=</span> <span class="identifier">a</span> <span class="special">;</span>
|
<span class="keyword">int</span><span class="special">&</span> <span class="identifier">ra</span> <span class="special">=</span> <span class="identifier">a</span> <span class="special">;</span>
|
||||||
<span class="keyword">int</span> <span class="identifier">b</span> <span class="special">=</span> <span class="number">2</span> <span class="special">;</span>
|
<span class="keyword">int</span> <span class="identifier">b</span> <span class="special">=</span> <span class="number">2</span> <span class="special">;</span>
|
||||||
<span class="keyword">int</span><span class="special">&</span> <span class="identifier">rb</span> <span class="special">=</span> <span class="identifier">b</span> <span class="special">;</span>
|
<span class="keyword">int</span><span class="special">&</span> <span class="identifier">rb</span> <span class="special">=</span> <span class="identifier">b</span> <span class="special">;</span>
|
||||||
@ -58,7 +62,8 @@
|
|||||||
the effect is to <span class="bold"><strong>rebind</strong></span> to the new object
|
the effect is to <span class="bold"><strong>rebind</strong></span> to the new object
|
||||||
instead of assigning the referee. This is unlike bare C++ references.
|
instead of assigning the referee. This is unlike bare C++ references.
|
||||||
</p>
|
</p>
|
||||||
<pre class="programlisting"><span class="keyword">int</span> <span class="identifier">a</span> <span class="special">=</span> <span class="number">1</span> <span class="special">;</span>
|
<pre class="programlisting">
|
||||||
|
<span class="keyword">int</span> <span class="identifier">a</span> <span class="special">=</span> <span class="number">1</span> <span class="special">;</span>
|
||||||
<span class="keyword">int</span> <span class="identifier">b</span> <span class="special">=</span> <span class="number">2</span> <span class="special">;</span>
|
<span class="keyword">int</span> <span class="identifier">b</span> <span class="special">=</span> <span class="number">2</span> <span class="special">;</span>
|
||||||
<span class="keyword">int</span><span class="special">&</span> <span class="identifier">ra</span> <span class="special">=</span> <span class="identifier">a</span> <span class="special">;</span>
|
<span class="keyword">int</span><span class="special">&</span> <span class="identifier">ra</span> <span class="special">=</span> <span class="identifier">a</span> <span class="special">;</span>
|
||||||
<span class="keyword">int</span><span class="special">&</span> <span class="identifier">rb</span> <span class="special">=</span> <span class="identifier">b</span> <span class="special">;</span>
|
<span class="keyword">int</span><span class="special">&</span> <span class="identifier">rb</span> <span class="special">=</span> <span class="identifier">b</span> <span class="special">;</span>
|
||||||
@ -70,8 +75,8 @@
|
|||||||
<span class="identifier">assert</span><span class="special">(</span><span class="identifier">b</span><span class="special">==</span><span class="number">3</span><span class="special">);</span>
|
<span class="identifier">assert</span><span class="special">(</span><span class="identifier">b</span><span class="special">==</span><span class="number">3</span><span class="special">);</span>
|
||||||
</pre>
|
</pre>
|
||||||
<a name="boost_optional.rebinding_semantics_for_assignment_of_optional_references.rationale"></a><h4>
|
<a name="boost_optional.rebinding_semantics_for_assignment_of_optional_references.rationale"></a><h4>
|
||||||
<a name="boost_optional.rebinding_semantics_for_assignment_of_optional_references.rationale-heading"></a>
|
<a name="id2640074"></a>
|
||||||
<a class="link" href="rebinding_semantics_for_assignment_of_optional_references.html#boost_optional.rebinding_semantics_for_assignment_of_optional_references.rationale">Rationale</a>
|
<a href="rebinding_semantics_for_assignment_of_optional_references.html#boost_optional.rebinding_semantics_for_assignment_of_optional_references.rationale">Rationale</a>
|
||||||
</h4>
|
</h4>
|
||||||
<p>
|
<p>
|
||||||
Rebinding semantics for the assignment of <span class="emphasis"><em>initialized </em></span>
|
Rebinding semantics for the assignment of <span class="emphasis"><em>initialized </em></span>
|
||||||
@ -90,7 +95,8 @@
|
|||||||
forwarding assignment to the referenced object (thus changing the referenced
|
forwarding assignment to the referenced object (thus changing the referenced
|
||||||
object value but not rebinding), and consider the following code:
|
object value but not rebinding), and consider the following code:
|
||||||
</p>
|
</p>
|
||||||
<pre class="programlisting"><span class="identifier">optional</span><span class="special"><</span><span class="keyword">int</span><span class="special">&></span> <span class="identifier">a</span> <span class="special">=</span> <span class="identifier">get</span><span class="special">();</span>
|
<pre class="programlisting">
|
||||||
|
<span class="identifier">optional</span><span class="special"><</span><span class="keyword">int</span><span class="special">&></span> <span class="identifier">a</span> <span class="special">=</span> <span class="identifier">get</span><span class="special">();</span>
|
||||||
<span class="keyword">int</span> <span class="identifier">x</span> <span class="special">=</span> <span class="number">1</span> <span class="special">;</span>
|
<span class="keyword">int</span> <span class="identifier">x</span> <span class="special">=</span> <span class="number">1</span> <span class="special">;</span>
|
||||||
<span class="keyword">int</span><span class="special">&</span> <span class="identifier">rx</span> <span class="special">=</span> <span class="identifier">x</span> <span class="special">;</span>
|
<span class="keyword">int</span><span class="special">&</span> <span class="identifier">rx</span> <span class="special">=</span> <span class="identifier">x</span> <span class="special">;</span>
|
||||||
<span class="identifier">optional</span><span class="special"><</span><span class="keyword">int</span><span class="special">&></span> <span class="identifier">b</span><span class="special">(</span><span class="identifier">rx</span><span class="special">);</span>
|
<span class="identifier">optional</span><span class="special"><</span><span class="keyword">int</span><span class="special">&></span> <span class="identifier">b</span><span class="special">(</span><span class="identifier">rx</span><span class="special">);</span>
|
||||||
@ -117,24 +123,25 @@
|
|||||||
or not.
|
or not.
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
That is, you would have to discriminate in order to be consistent.
|
That is, you would have to discriminate in order to be consistency.
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
If in your code rebinding to another object is not an option, then it is very
|
If in your code rebinding to another object is not an option, then is very
|
||||||
likely that binding for the first time isn't either. In such case, assignment
|
likely that binding for the fist time isn't either. In such case, assignment
|
||||||
to an <span class="emphasis"><em>uninitialized </em></span> <code class="computeroutput"><span class="identifier">optional</span><span class="special"><</span><span class="identifier">T</span><span class="special">&></span></code>
|
to an <span class="emphasis"><em>uninitialized </em></span> <code class="computeroutput"><span class="identifier">optional</span><span class="special"><</span><span class="identifier">T</span><span class="special">&></span></code>
|
||||||
shall be prohibited. It is quite possible that in such a scenario it is a precondition
|
shall be prohibited. It is quite possible that in such scenario the precondition
|
||||||
that the lvalue must be already initialized. If it isn't, then binding for
|
that the lvalue must be already initialized exist. If it doesn't, then binding
|
||||||
the first time is OK while rebinding is not which is IMO very unlikely. In
|
for the first time is OK while rebinding is not which is IMO very unlikely.
|
||||||
such a scenario, you can assign the value itself directly, as in:
|
In such scenario, you can assign the value itself directly, as in:
|
||||||
</p>
|
</p>
|
||||||
<pre class="programlisting"><span class="identifier">assert</span><span class="special">(!!</span><span class="identifier">opt</span><span class="special">);</span>
|
<pre class="programlisting">
|
||||||
|
<span class="identifier">assert</span><span class="special">(!!</span><span class="identifier">opt</span><span class="special">);</span>
|
||||||
<span class="special">*</span><span class="identifier">opt</span><span class="special">=</span><span class="identifier">value</span><span class="special">;</span>
|
<span class="special">*</span><span class="identifier">opt</span><span class="special">=</span><span class="identifier">value</span><span class="special">;</span>
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
</div>
|
||||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||||||
<td align="left"></td>
|
<td align="left"></td>
|
||||||
<td align="right"><div class="copyright-footer">Copyright © 2003-2007 Fernando Luis Cacciola Carballal<p>
|
<td align="right"><div class="copyright-footer">Copyright <EFBFBD> 2003 -2007 Fernando Luis Cacciola Carballal<p>
|
||||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||||
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
|
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
|
||||||
</p>
|
</p>
|
||||||
@ -142,7 +149,7 @@
|
|||||||
</tr></table>
|
</tr></table>
|
||||||
<hr>
|
<hr>
|
||||||
<div class="spirit-nav">
|
<div class="spirit-nav">
|
||||||
<a accesskey="p" href="optional_references.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><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="in_place_factories.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
|
<a accesskey="p" href="optional_references.html"><img src="../../../../../doc/html/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/html/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/html/images/home.png" alt="Home"></a><a accesskey="n" href="in_place_factories.html"><img src="../../../../../doc/html/images/next.png" alt="Next"></a>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
@ -1,33 +1,32 @@
|
|||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
||||||
<title>Synopsis</title>
|
<title>Synopsis</title>
|
||||||
<link rel="stylesheet" href="../boostbook.css" type="text/css">
|
<link rel="stylesheet" href="../boostbook.css" type="text/css">
|
||||||
<meta name="generator" content="DocBook XSL Stylesheets V1.75.2">
|
<meta name="generator" content="DocBook XSL Stylesheets V1.70.1">
|
||||||
<link rel="home" href="../index.html" title="Chapter 1. Boost.Optional">
|
<link rel="start" href="../index.html" title="Chapter<EFBFBD>1.<2E>Boost.Optional">
|
||||||
<link rel="up" href="../index.html" title="Chapter 1. Boost.Optional">
|
<link rel="up" href="../index.html" title="Chapter<EFBFBD>1.<2E>Boost.Optional">
|
||||||
<link rel="prev" href="development.html" title="Development">
|
<link rel="prev" href="development.html" title="Development">
|
||||||
<link rel="next" href="detailed_semantics.html" title="Detailed Semantics">
|
<link rel="next" href="detailed_semantics.html" title="Detailed Semantics">
|
||||||
</head>
|
</head>
|
||||||
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
||||||
<table cellpadding="2" width="100%"><tr>
|
<table cellpadding="2" width="100%"><tr>
|
||||||
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../boost.png"></td>
|
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../boost.png"></td>
|
||||||
<td align="center"><a href="../../../../../index.html">Home</a></td>
|
<td align="center"><a href="../../../../../index.htm">Home</a></td>
|
||||||
<td align="center"><a href="../../../../../libs/libraries.htm">Libraries</a></td>
|
<td align="center"><a href="../../../../libraries.htm">Libraries</a></td>
|
||||||
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
|
<td align="center"><a href="http://www.boost.org/people/people.htm">People</a></td>
|
||||||
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
|
<td align="center"><a href="http://www.boost.org/more/faq.htm">FAQ</a></td>
|
||||||
<td align="center"><a href="../../../../../more/index.htm">More</a></td>
|
<td align="center"><a href="../../../../../more/index.htm">More</a></td>
|
||||||
</tr></table>
|
</tr></table>
|
||||||
<hr>
|
<hr>
|
||||||
<div class="spirit-nav">
|
<div class="spirit-nav">
|
||||||
<a accesskey="p" href="development.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><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="detailed_semantics.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
|
<a accesskey="p" href="development.html"><img src="../../../../../doc/html/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/html/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/html/images/home.png" alt="Home"></a><a accesskey="n" href="detailed_semantics.html"><img src="../../../../../doc/html/images/next.png" alt="Next"></a>
|
||||||
</div>
|
</div>
|
||||||
<div class="section">
|
<div class="section" lang="en">
|
||||||
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
|
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
|
||||||
<a name="boost_optional.synopsis"></a><a class="link" href="synopsis.html" title="Synopsis">Synopsis</a>
|
<a name="boost_optional.synopsis"></a><a href="synopsis.html" title="Synopsis">Synopsis</a>
|
||||||
</h2></div></div></div>
|
</h2></div></div></div>
|
||||||
<pre class="programlisting"><code class="computeroutput"><span class="comment">// In Header: <</span></code><a href="../../../../../boost/optional/optional.hpp" target="_top">boost/optional/optional.hpp</a><span class="comment">></span>
|
<pre class="programlisting">
|
||||||
|
|
||||||
<span class="keyword">namespace</span> <span class="identifier">boost</span> <span class="special">{</span>
|
<span class="keyword">namespace</span> <span class="identifier">boost</span> <span class="special">{</span>
|
||||||
|
|
||||||
<span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">></span>
|
<span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">></span>
|
||||||
@ -37,108 +36,108 @@
|
|||||||
|
|
||||||
<span class="comment">// (If T is of reference type, the parameters and results by reference are by value)
|
<span class="comment">// (If T is of reference type, the parameters and results by reference are by value)
|
||||||
</span>
|
</span>
|
||||||
<span class="identifier">optional</span> <span class="special">()</span> <span class="special">;</span> <a class="link" href="detailed_semantics.html#reference_optional_constructor"><span class="inlinemediaobject"><img src="../images/callouts/R.png" alt="R"></span></a>
|
<span class="identifier">optional</span> <span class="special">()</span> <span class="special">;</span> <a href="detailed_semantics.html#reference_optional_constructor"><span class="inlinemediaobject"><img src="../images/callouts/R.png" alt="R"></span></a>
|
||||||
|
|
||||||
<span class="identifier">optional</span> <span class="special">(</span> <span class="identifier">none_t</span> <span class="special">)</span> <span class="special">;</span> <a class="link" href="detailed_semantics.html#reference_optional_constructor_none_t"><span class="inlinemediaobject"><img src="../images/callouts/R.png" alt="R"></span></a>
|
<span class="identifier">optional</span> <span class="special">(</span> <span class="identifier">none_t</span> <span class="special">)</span> <span class="special">;</span> <a href="detailed_semantics.html#reference_optional_constructor_none_t"><span class="inlinemediaobject"><img src="../images/callouts/R.png" alt="R"></span></a>
|
||||||
|
|
||||||
<span class="identifier">optional</span> <span class="special">(</span> <span class="identifier">T</span> <span class="keyword">const</span><span class="special">&</span> <span class="identifier">v</span> <span class="special">)</span> <span class="special">;</span> <a class="link" href="detailed_semantics.html#reference_optional_constructor_value"><span class="inlinemediaobject"><img src="../images/callouts/R.png" alt="R"></span></a>
|
<span class="identifier">optional</span> <span class="special">(</span> <span class="identifier">T</span> <span class="keyword">const</span><span class="special">&</span> <span class="identifier">v</span> <span class="special">)</span> <span class="special">;</span> <a href="detailed_semantics.html#reference_optional_constructor_value"><span class="inlinemediaobject"><img src="../images/callouts/R.png" alt="R"></span></a>
|
||||||
|
|
||||||
<span class="comment">// [new in 1.34]
|
<span class="comment">// [new in 1.34]
|
||||||
</span> <span class="identifier">optional</span> <span class="special">(</span> <span class="keyword">bool</span> <span class="identifier">condition</span><span class="special">,</span> <span class="identifier">T</span> <span class="keyword">const</span><span class="special">&</span> <span class="identifier">v</span> <span class="special">)</span> <span class="special">;</span> <a class="link" href="detailed_semantics.html#reference_optional_constructor_bool_value"><span class="inlinemediaobject"><img src="../images/callouts/R.png" alt="R"></span></a>
|
</span> <span class="identifier">optional</span> <span class="special">(</span> <span class="keyword">bool</span> <span class="identifier">condition</span><span class="special">,</span> <span class="identifier">T</span> <span class="keyword">const</span><span class="special">&</span> <span class="identifier">v</span> <span class="special">)</span> <span class="special">;</span> <a href="detailed_semantics.html#reference_optional_constructor_bool_value"><span class="inlinemediaobject"><img src="../images/callouts/R.png" alt="R"></span></a>
|
||||||
|
|
||||||
<span class="identifier">optional</span> <span class="special">(</span> <span class="identifier">optional</span> <span class="keyword">const</span><span class="special">&</span> <span class="identifier">rhs</span> <span class="special">)</span> <span class="special">;</span> <a class="link" href="detailed_semantics.html#reference_optional_constructor_optional"><span class="inlinemediaobject"><img src="../images/callouts/R.png" alt="R"></span></a>
|
<span class="identifier">optional</span> <span class="special">(</span> <span class="identifier">optional</span> <span class="keyword">const</span><span class="special">&</span> <span class="identifier">rhs</span> <span class="special">)</span> <span class="special">;</span> <a href="detailed_semantics.html#reference_optional_constructor_optional"><span class="inlinemediaobject"><img src="../images/callouts/R.png" alt="R"></span></a>
|
||||||
|
|
||||||
<span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">U</span><span class="special">></span> <span class="keyword">explicit</span> <span class="identifier">optional</span> <span class="special">(</span> <span class="identifier">optional</span><span class="special"><</span><span class="identifier">U</span><span class="special">></span> <span class="keyword">const</span><span class="special">&</span> <span class="identifier">rhs</span> <span class="special">)</span> <span class="special">;</span> <a class="link" href="detailed_semantics.html#reference_optional_constructor_other_optional"><span class="inlinemediaobject"><img src="../images/callouts/R.png" alt="R"></span></a>
|
<span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">U</span><span class="special">></span> <span class="keyword">explicit</span> <span class="identifier">optional</span> <span class="special">(</span> <span class="identifier">optional</span><span class="special"><</span><span class="identifier">U</span><span class="special">></span> <span class="keyword">const</span><span class="special">&</span> <span class="identifier">rhs</span> <span class="special">)</span> <span class="special">;</span> <a href="detailed_semantics.html#reference_optional_constructor_other_optional"><span class="inlinemediaobject"><img src="../images/callouts/R.png" alt="R"></span></a>
|
||||||
|
|
||||||
<span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">InPlaceFactory</span><span class="special">></span> <span class="keyword">explicit</span> <span class="identifier">optional</span> <span class="special">(</span> <span class="identifier">InPlaceFactory</span> <span class="keyword">const</span><span class="special">&</span> <span class="identifier">f</span> <span class="special">)</span> <span class="special">;</span> <a class="link" href="detailed_semantics.html#reference_optional_constructor_factory"><span class="inlinemediaobject"><img src="../images/callouts/R.png" alt="R"></span></a>
|
<span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">InPlaceFactory</span><span class="special">></span> <span class="keyword">explicit</span> <span class="identifier">optional</span> <span class="special">(</span> <span class="identifier">InPlaceFactory</span> <span class="keyword">const</span><span class="special">&</span> <span class="identifier">f</span> <span class="special">)</span> <span class="special">;</span> <a href="detailed_semantics.html#reference_optional_constructor_factory"><span class="inlinemediaobject"><img src="../images/callouts/R.png" alt="R"></span></a>
|
||||||
|
|
||||||
<span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">TypedInPlaceFactory</span><span class="special">></span> <span class="keyword">explicit</span> <span class="identifier">optional</span> <span class="special">(</span> <span class="identifier">TypedInPlaceFactory</span> <span class="keyword">const</span><span class="special">&</span> <span class="identifier">f</span> <span class="special">)</span> <span class="special">;</span> <a class="link" href="detailed_semantics.html#reference_optional_constructor_factory"><span class="inlinemediaobject"><img src="../images/callouts/R.png" alt="R"></span></a>
|
<span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">TypedInPlaceFactory</span><span class="special">></span> <span class="keyword">explicit</span> <span class="identifier">optional</span> <span class="special">(</span> <span class="identifier">TypedInPlaceFactory</span> <span class="keyword">const</span><span class="special">&</span> <span class="identifier">f</span> <span class="special">)</span> <span class="special">;</span> <a href="detailed_semantics.html#reference_optional_constructor_factory"><span class="inlinemediaobject"><img src="../images/callouts/R.png" alt="R"></span></a>
|
||||||
|
|
||||||
<span class="identifier">optional</span><span class="special">&</span> <span class="keyword">operator</span> <span class="special">=</span> <span class="special">(</span> <span class="identifier">none_t</span> <span class="special">)</span> <span class="special">;</span>
|
<span class="identifier">optional</span><span class="special">&</span> <span class="keyword">operator</span> <span class="special">=</span> <span class="special">(</span> <span class="identifier">none_t</span> <span class="special">)</span> <span class="special">;</span>
|
||||||
|
|
||||||
<span class="identifier">optional</span><span class="special">&</span> <span class="keyword">operator</span> <span class="special">=</span> <span class="special">(</span> <span class="identifier">T</span> <span class="keyword">const</span><span class="special">&</span> <span class="identifier">v</span> <span class="special">)</span> <span class="special">;</span> <a class="link" href="detailed_semantics.html#reference_optional_operator_equal_value"><span class="inlinemediaobject"><img src="../images/callouts/R.png" alt="R"></span></a>
|
<span class="identifier">optional</span><span class="special">&</span> <span class="keyword">operator</span> <span class="special">=</span> <span class="special">(</span> <span class="identifier">T</span> <span class="keyword">const</span><span class="special">&</span> <span class="identifier">v</span> <span class="special">)</span> <span class="special">;</span> <a href="detailed_semantics.html#reference_optional_operator_equal_value"><span class="inlinemediaobject"><img src="../images/callouts/R.png" alt="R"></span></a>
|
||||||
|
|
||||||
<span class="identifier">optional</span><span class="special">&</span> <span class="keyword">operator</span> <span class="special">=</span> <span class="special">(</span> <span class="identifier">optional</span> <span class="keyword">const</span><span class="special">&</span> <span class="identifier">rhs</span> <span class="special">)</span> <span class="special">;</span> <a class="link" href="detailed_semantics.html#reference_optional_operator_equal_optional"><span class="inlinemediaobject"><img src="../images/callouts/R.png" alt="R"></span></a>
|
<span class="identifier">optional</span><span class="special">&</span> <span class="keyword">operator</span> <span class="special">=</span> <span class="special">(</span> <span class="identifier">optional</span> <span class="keyword">const</span><span class="special">&</span> <span class="identifier">rhs</span> <span class="special">)</span> <span class="special">;</span> <a href="detailed_semantics.html#reference_optional_operator_equal_optional"><span class="inlinemediaobject"><img src="../images/callouts/R.png" alt="R"></span></a>
|
||||||
|
|
||||||
<span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">U</span><span class="special">></span> <span class="identifier">optional</span><span class="special">&</span> <span class="keyword">operator</span> <span class="special">=</span> <span class="special">(</span> <span class="identifier">optional</span><span class="special"><</span><span class="identifier">U</span><span class="special">></span> <span class="keyword">const</span><span class="special">&</span> <span class="identifier">rhs</span> <span class="special">)</span> <span class="special">;</span> <a class="link" href="detailed_semantics.html#reference_optional_operator_equal_other_optional"><span class="inlinemediaobject"><img src="../images/callouts/R.png" alt="R"></span></a>
|
<span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">U</span><span class="special">></span> <span class="identifier">optional</span><span class="special">&</span> <span class="keyword">operator</span> <span class="special">=</span> <span class="special">(</span> <span class="identifier">optional</span><span class="special"><</span><span class="identifier">U</span><span class="special">></span> <span class="keyword">const</span><span class="special">&</span> <span class="identifier">rhs</span> <span class="special">)</span> <span class="special">;</span> <a href="detailed_semantics.html#reference_optional_operator_equal_other_optional"><span class="inlinemediaobject"><img src="../images/callouts/R.png" alt="R"></span></a>
|
||||||
|
|
||||||
<span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">InPlaceFactory</span><span class="special">></span> <span class="identifier">optional</span><span class="special">&</span> <span class="keyword">operator</span> <span class="special">=</span> <span class="special">(</span> <span class="identifier">InPlaceFactory</span> <span class="keyword">const</span><span class="special">&</span> <span class="identifier">f</span> <span class="special">)</span> <span class="special">;</span> <a class="link" href="detailed_semantics.html#reference_optional_operator_equal_factory"><span class="inlinemediaobject"><img src="../images/callouts/R.png" alt="R"></span></a>
|
<span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">InPlaceFactory</span><span class="special">></span> <span class="identifier">optional</span><span class="special">&</span> <span class="keyword">operator</span> <span class="special">=</span> <span class="special">(</span> <span class="identifier">InPlaceFactory</span> <span class="keyword">const</span><span class="special">&</span> <span class="identifier">f</span> <span class="special">)</span> <span class="special">;</span>
|
||||||
|
|
||||||
<span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">TypedInPlaceFactory</span><span class="special">></span> <span class="identifier">optional</span><span class="special">&</span> <span class="keyword">operator</span> <span class="special">=</span> <span class="special">(</span> <span class="identifier">TypedInPlaceFactory</span> <span class="keyword">const</span><span class="special">&</span> <span class="identifier">f</span> <span class="special">)</span> <span class="special">;</span> <a class="link" href="detailed_semantics.html#reference_optional_operator_equal_factory"><span class="inlinemediaobject"><img src="../images/callouts/R.png" alt="R"></span></a>
|
<span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">TypedInPlaceFactory</span><span class="special">></span> <span class="identifier">optional</span><span class="special">&</span> <span class="keyword">operator</span> <span class="special">=</span> <span class="special">(</span> <span class="identifier">TypedInPlaceFactory</span> <span class="keyword">const</span><span class="special">&</span> <span class="identifier">f</span> <span class="special">)</span> <span class="special">;</span>
|
||||||
|
|
||||||
<span class="identifier">T</span> <span class="keyword">const</span><span class="special">&</span> <span class="identifier">get</span><span class="special">()</span> <span class="keyword">const</span> <span class="special">;</span> <a class="link" href="detailed_semantics.html#reference_optional_get"><span class="inlinemediaobject"><img src="../images/callouts/R.png" alt="R"></span></a>
|
<span class="identifier">T</span> <span class="keyword">const</span><span class="special">&</span> <span class="identifier">get</span><span class="special">()</span> <span class="keyword">const</span> <span class="special">;</span> <a href="detailed_semantics.html#reference_optional_get"><span class="inlinemediaobject"><img src="../images/callouts/R.png" alt="R"></span></a>
|
||||||
<span class="identifier">T</span><span class="special">&</span> <span class="identifier">get</span><span class="special">()</span> <span class="special">;</span> <a class="link" href="detailed_semantics.html#reference_optional_get"><span class="inlinemediaobject"><img src="../images/callouts/R.png" alt="R"></span></a>
|
<span class="identifier">T</span><span class="special">&</span> <span class="identifier">get</span><span class="special">()</span> <span class="special">;</span> <a href="detailed_semantics.html#reference_optional_get"><span class="inlinemediaobject"><img src="../images/callouts/R.png" alt="R"></span></a>
|
||||||
|
|
||||||
<span class="comment">// [new in 1.34]
|
<span class="comment">// [new in 1.34]
|
||||||
</span> <span class="identifier">T</span> <span class="keyword">const</span><span class="special">&</span> <span class="identifier">get_value_or</span><span class="special">(</span> <span class="identifier">T</span> <span class="keyword">const</span><span class="special">&</span> <span class="keyword">default</span> <span class="special">)</span> <span class="keyword">const</span> <span class="special">;</span> <a class="link" href="detailed_semantics.html#reference_optional_get_value_or_value"><span class="inlinemediaobject"><img src="../images/callouts/R.png" alt="R"></span></a>
|
</span> <span class="identifier">T</span> <span class="keyword">const</span><span class="special">&</span> <span class="identifier">get_value_or</span><span class="special">(</span> <span class="identifier">T</span> <span class="keyword">const</span><span class="special">&</span> <span class="keyword">default</span> <span class="special">)</span> <span class="keyword">const</span> <span class="special">;</span> <a href="detailed_semantics.html#reference_optional_get_value_or_value"><span class="inlinemediaobject"><img src="../images/callouts/R.png" alt="R"></span></a>
|
||||||
|
|
||||||
<span class="identifier">T</span> <span class="keyword">const</span><span class="special">*</span> <span class="keyword">operator</span> <span class="special">->()</span> <span class="keyword">const</span> <span class="special">;</span> <a class="link" href="detailed_semantics.html#reference_optional_operator_arrow"><span class="inlinemediaobject"><img src="../images/callouts/R.png" alt="R"></span></a>
|
<span class="identifier">T</span> <span class="keyword">const</span><span class="special">*</span> <span class="keyword">operator</span> <span class="special">->()</span> <span class="keyword">const</span> <span class="special">;</span> <a href="detailed_semantics.html#reference_optional_operator_arrow"><span class="inlinemediaobject"><img src="../images/callouts/R.png" alt="R"></span></a>
|
||||||
<span class="identifier">T</span><span class="special">*</span> <span class="keyword">operator</span> <span class="special">->()</span> <span class="special">;</span> <a class="link" href="detailed_semantics.html#reference_optional_operator_arrow"><span class="inlinemediaobject"><img src="../images/callouts/R.png" alt="R"></span></a>
|
<span class="identifier">T</span><span class="special">*</span> <span class="keyword">operator</span> <span class="special">->()</span> <span class="special">;</span> <a href="detailed_semantics.html#reference_optional_operator_arrow"><span class="inlinemediaobject"><img src="../images/callouts/R.png" alt="R"></span></a>
|
||||||
|
|
||||||
<span class="identifier">T</span> <span class="keyword">const</span><span class="special">&</span> <span class="keyword">operator</span> <span class="special">*()</span> <span class="keyword">const</span> <span class="special">;</span> <a class="link" href="detailed_semantics.html#reference_optional_get"><span class="inlinemediaobject"><img src="../images/callouts/R.png" alt="R"></span></a>
|
<span class="identifier">T</span> <span class="keyword">const</span><span class="special">&</span> <span class="keyword">operator</span> <span class="special">*()</span> <span class="keyword">const</span> <span class="special">;</span> <a href="detailed_semantics.html#reference_optional_get"><span class="inlinemediaobject"><img src="../images/callouts/R.png" alt="R"></span></a>
|
||||||
<span class="identifier">T</span><span class="special">&</span> <span class="keyword">operator</span> <span class="special">*()</span> <span class="special">;</span> <a class="link" href="detailed_semantics.html#reference_optional_get"><span class="inlinemediaobject"><img src="../images/callouts/R.png" alt="R"></span></a>
|
<span class="identifier">T</span><span class="special">&</span> <span class="keyword">operator</span> <span class="special">*()</span> <span class="special">;</span> <a href="detailed_semantics.html#reference_optional_get"><span class="inlinemediaobject"><img src="../images/callouts/R.png" alt="R"></span></a>
|
||||||
|
|
||||||
<span class="identifier">T</span> <span class="keyword">const</span><span class="special">*</span> <span class="identifier">get_ptr</span><span class="special">()</span> <span class="keyword">const</span> <span class="special">;</span> <a class="link" href="detailed_semantics.html#reference_optional_get_ptr"><span class="inlinemediaobject"><img src="../images/callouts/R.png" alt="R"></span></a>
|
<span class="identifier">T</span> <span class="keyword">const</span><span class="special">*</span> <span class="identifier">get_ptr</span><span class="special">()</span> <span class="keyword">const</span> <span class="special">;</span> <a href="detailed_semantics.html#reference_optional_get_ptr"><span class="inlinemediaobject"><img src="../images/callouts/R.png" alt="R"></span></a>
|
||||||
<span class="identifier">T</span><span class="special">*</span> <span class="identifier">get_ptr</span><span class="special">()</span> <span class="special">;</span> <a class="link" href="detailed_semantics.html#reference_optional_get_ptr"><span class="inlinemediaobject"><img src="../images/callouts/R.png" alt="R"></span></a>
|
<span class="identifier">T</span><span class="special">*</span> <span class="identifier">get_ptr</span><span class="special">()</span> <span class="special">;</span> <a href="detailed_semantics.html#reference_optional_get_ptr"><span class="inlinemediaobject"><img src="../images/callouts/R.png" alt="R"></span></a>
|
||||||
|
|
||||||
<span class="keyword">operator</span> <span class="identifier">unspecified</span><span class="special">-</span><span class="keyword">bool</span><span class="special">-</span><span class="identifier">type</span><span class="special">()</span> <span class="keyword">const</span> <span class="special">;</span> <a class="link" href="detailed_semantics.html#reference_optional_operator_bool"><span class="inlinemediaobject"><img src="../images/callouts/R.png" alt="R"></span></a>
|
<span class="keyword">operator</span> <span class="identifier">unspecified</span><span class="special">-</span><span class="keyword">bool</span><span class="special">-</span><span class="identifier">type</span><span class="special">()</span> <span class="keyword">const</span> <span class="special">;</span> <a href="detailed_semantics.html#reference_optional_operator_bool"><span class="inlinemediaobject"><img src="../images/callouts/R.png" alt="R"></span></a>
|
||||||
|
|
||||||
<span class="keyword">bool</span> <span class="keyword">operator</span><span class="special">!()</span> <span class="keyword">const</span> <span class="special">;</span> <a class="link" href="detailed_semantics.html#reference_optional_operator_not"><span class="inlinemediaobject"><img src="../images/callouts/R.png" alt="R"></span></a>
|
<span class="keyword">bool</span> <span class="keyword">operator</span><span class="special">!()</span> <span class="keyword">const</span> <span class="special">;</span> <a href="detailed_semantics.html#reference_optional_operator_not"><span class="inlinemediaobject"><img src="../images/callouts/R.png" alt="R"></span></a>
|
||||||
|
|
||||||
<span class="comment">// deprecated methods
|
<span class="comment">// deprecated methods
|
||||||
</span>
|
</span>
|
||||||
<span class="comment">// (deprecated)
|
<span class="comment">// (deprecated)
|
||||||
</span> <span class="keyword">void</span> <span class="identifier">reset</span><span class="special">()</span> <span class="special">;</span> <a class="link" href="detailed_semantics.html#reference_optional_reset"><span class="inlinemediaobject"><img src="../images/callouts/R.png" alt="R"></span></a>
|
</span> <span class="keyword">void</span> <span class="identifier">reset</span><span class="special">()</span> <span class="special">;</span> <a href="detailed_semantics.html#reference_optional_reset"><span class="inlinemediaobject"><img src="../images/callouts/R.png" alt="R"></span></a>
|
||||||
|
|
||||||
<span class="comment">// (deprecated)
|
<span class="comment">// (deprecated)
|
||||||
</span> <span class="keyword">void</span> <span class="identifier">reset</span> <span class="special">(</span> <span class="identifier">T</span> <span class="keyword">const</span><span class="special">&</span> <span class="special">)</span> <span class="special">;</span> <a class="link" href="detailed_semantics.html#reference_optional_reset_value"><span class="inlinemediaobject"><img src="../images/callouts/R.png" alt="R"></span></a>
|
</span> <span class="keyword">void</span> <span class="identifier">reset</span> <span class="special">(</span> <span class="identifier">T</span> <span class="keyword">const</span><span class="special">&</span> <span class="special">)</span> <span class="special">;</span> <a href="detailed_semantics.html#reference_optional_reset_value"><span class="inlinemediaobject"><img src="../images/callouts/R.png" alt="R"></span></a>
|
||||||
|
|
||||||
<span class="comment">// (deprecated)
|
<span class="comment">// (deprecated)
|
||||||
</span> <span class="keyword">bool</span> <span class="identifier">is_initialized</span><span class="special">()</span> <span class="keyword">const</span> <span class="special">;</span> <a class="link" href="detailed_semantics.html#reference_optional_is_initialized"><span class="inlinemediaobject"><img src="../images/callouts/R.png" alt="R"></span></a>
|
</span> <span class="keyword">bool</span> <span class="identifier">is_initialized</span><span class="special">()</span> <span class="keyword">const</span> <span class="special">;</span> <a href="detailed_semantics.html#reference_optional_is_initialized"><span class="inlinemediaobject"><img src="../images/callouts/R.png" alt="R"></span></a>
|
||||||
|
|
||||||
<span class="special">};</span>
|
<span class="special">};</span>
|
||||||
|
|
||||||
<span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">></span> <span class="keyword">inline</span> <span class="keyword">bool</span> <span class="keyword">operator</span> <span class="special">==</span> <span class="special">(</span> <span class="identifier">optional</span><span class="special"><</span><span class="identifier">T</span><span class="special">></span> <span class="keyword">const</span><span class="special">&</span> <span class="identifier">x</span><span class="special">,</span> <span class="identifier">optional</span><span class="special"><</span><span class="identifier">T</span><span class="special">></span> <span class="keyword">const</span><span class="special">&</span> <span class="identifier">y</span> <span class="special">)</span> <span class="special">;</span> <a class="link" href="detailed_semantics.html#reference_operator_compare_equal_optional_optional"><span class="inlinemediaobject"><img src="../images/callouts/R.png" alt="R"></span></a>
|
<span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">></span> <span class="keyword">inline</span> <span class="keyword">bool</span> <span class="keyword">operator</span> <span class="special">==</span> <span class="special">(</span> <span class="identifier">optional</span><span class="special"><</span><span class="identifier">T</span><span class="special">></span> <span class="keyword">const</span><span class="special">&</span> <span class="identifier">x</span><span class="special">,</span> <span class="identifier">optional</span><span class="special"><</span><span class="identifier">T</span><span class="special">></span> <span class="keyword">const</span><span class="special">&</span> <span class="identifier">y</span> <span class="special">)</span> <span class="special">;</span> <a href="detailed_semantics.html#reference_operator_compare_equal_optional_optional"><span class="inlinemediaobject"><img src="../images/callouts/R.png" alt="R"></span></a>
|
||||||
|
|
||||||
<span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">></span> <span class="keyword">inline</span> <span class="keyword">bool</span> <span class="keyword">operator</span> <span class="special">!=</span> <span class="special">(</span> <span class="identifier">optional</span><span class="special"><</span><span class="identifier">T</span><span class="special">></span> <span class="keyword">const</span><span class="special">&</span> <span class="identifier">x</span><span class="special">,</span> <span class="identifier">optional</span><span class="special"><</span><span class="identifier">T</span><span class="special">></span> <span class="keyword">const</span><span class="special">&</span> <span class="identifier">y</span> <span class="special">)</span> <span class="special">;</span> <a class="link" href="detailed_semantics.html#reference_operator_compare_not_equal_optional_optional"><span class="inlinemediaobject"><img src="../images/callouts/R.png" alt="R"></span></a>
|
<span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">></span> <span class="keyword">inline</span> <span class="keyword">bool</span> <span class="keyword">operator</span> <span class="special">!=</span> <span class="special">(</span> <span class="identifier">optional</span><span class="special"><</span><span class="identifier">T</span><span class="special">></span> <span class="keyword">const</span><span class="special">&</span> <span class="identifier">x</span><span class="special">,</span> <span class="identifier">optional</span><span class="special"><</span><span class="identifier">T</span><span class="special">></span> <span class="keyword">const</span><span class="special">&</span> <span class="identifier">y</span> <span class="special">)</span> <span class="special">;</span> <a href="detailed_semantics.html#reference_operator_compare_not_equal_optional_optional"><span class="inlinemediaobject"><img src="../images/callouts/R.png" alt="R"></span></a>
|
||||||
|
|
||||||
<span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">></span> <span class="keyword">inline</span> <span class="keyword">bool</span> <span class="keyword">operator</span> <span class="special"><</span> <span class="special">(</span> <span class="identifier">optional</span><span class="special"><</span><span class="identifier">T</span><span class="special">></span> <span class="keyword">const</span><span class="special">&</span> <span class="identifier">x</span><span class="special">,</span> <span class="identifier">optional</span><span class="special"><</span><span class="identifier">T</span><span class="special">></span> <span class="keyword">const</span><span class="special">&</span> <span class="identifier">y</span> <span class="special">)</span> <span class="special">;</span> <a class="link" href="detailed_semantics.html#reference_operator_compare_less_optional_optional"><span class="inlinemediaobject"><img src="../images/callouts/R.png" alt="R"></span></a>
|
<span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">></span> <span class="keyword">inline</span> <span class="keyword">bool</span> <span class="keyword">operator</span> <span class="special"><</span> <span class="special">(</span> <span class="identifier">optional</span><span class="special"><</span><span class="identifier">T</span><span class="special">></span> <span class="keyword">const</span><span class="special">&</span> <span class="identifier">x</span><span class="special">,</span> <span class="identifier">optional</span><span class="special"><</span><span class="identifier">T</span><span class="special">></span> <span class="keyword">const</span><span class="special">&</span> <span class="identifier">y</span> <span class="special">)</span> <span class="special">;</span> <a href="detailed_semantics.html#reference_operator_compare_less_optional_optional"><span class="inlinemediaobject"><img src="../images/callouts/R.png" alt="R"></span></a>
|
||||||
|
|
||||||
<span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">></span> <span class="keyword">inline</span> <span class="keyword">bool</span> <span class="keyword">operator</span> <span class="special">></span> <span class="special">(</span> <span class="identifier">optional</span><span class="special"><</span><span class="identifier">T</span><span class="special">></span> <span class="keyword">const</span><span class="special">&</span> <span class="identifier">x</span><span class="special">,</span> <span class="identifier">optional</span><span class="special"><</span><span class="identifier">T</span><span class="special">></span> <span class="keyword">const</span><span class="special">&</span> <span class="identifier">y</span> <span class="special">)</span> <span class="special">;</span> <a class="link" href="detailed_semantics.html#reference_operator_compare_greater_optional_optional"><span class="inlinemediaobject"><img src="../images/callouts/R.png" alt="R"></span></a>
|
<span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">></span> <span class="keyword">inline</span> <span class="keyword">bool</span> <span class="keyword">operator</span> <span class="special">></span> <span class="special">(</span> <span class="identifier">optional</span><span class="special"><</span><span class="identifier">T</span><span class="special">></span> <span class="keyword">const</span><span class="special">&</span> <span class="identifier">x</span><span class="special">,</span> <span class="identifier">optional</span><span class="special"><</span><span class="identifier">T</span><span class="special">></span> <span class="keyword">const</span><span class="special">&</span> <span class="identifier">y</span> <span class="special">)</span> <span class="special">;</span> <a href="detailed_semantics.html#reference_operator_compare_greater_optional_optional"><span class="inlinemediaobject"><img src="../images/callouts/R.png" alt="R"></span></a>
|
||||||
|
|
||||||
<span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">></span> <span class="keyword">inline</span> <span class="keyword">bool</span> <span class="keyword">operator</span> <span class="special"><=</span> <span class="special">(</span> <span class="identifier">optional</span><span class="special"><</span><span class="identifier">T</span><span class="special">></span> <span class="keyword">const</span><span class="special">&</span> <span class="identifier">x</span><span class="special">,</span> <span class="identifier">optional</span><span class="special"><</span><span class="identifier">T</span><span class="special">></span> <span class="keyword">const</span><span class="special">&</span> <span class="identifier">y</span> <span class="special">)</span> <span class="special">;</span> <a class="link" href="detailed_semantics.html#reference_operator_compare_less_or_equal_optional_optional"><span class="inlinemediaobject"><img src="../images/callouts/R.png" alt="R"></span></a>
|
<span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">></span> <span class="keyword">inline</span> <span class="keyword">bool</span> <span class="keyword">operator</span> <span class="special"><=</span> <span class="special">(</span> <span class="identifier">optional</span><span class="special"><</span><span class="identifier">T</span><span class="special">></span> <span class="keyword">const</span><span class="special">&</span> <span class="identifier">x</span><span class="special">,</span> <span class="identifier">optional</span><span class="special"><</span><span class="identifier">T</span><span class="special">></span> <span class="keyword">const</span><span class="special">&</span> <span class="identifier">y</span> <span class="special">)</span> <span class="special">;</span> <a href="detailed_semantics.html#reference_operator_compare_less_or_equal_optional_optional"><span class="inlinemediaobject"><img src="../images/callouts/R.png" alt="R"></span></a>
|
||||||
|
|
||||||
<span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">></span> <span class="keyword">inline</span> <span class="keyword">bool</span> <span class="keyword">operator</span> <span class="special">>=</span> <span class="special">(</span> <span class="identifier">optional</span><span class="special"><</span><span class="identifier">T</span><span class="special">></span> <span class="keyword">const</span><span class="special">&</span> <span class="identifier">x</span><span class="special">,</span> <span class="identifier">optional</span><span class="special"><</span><span class="identifier">T</span><span class="special">></span> <span class="keyword">const</span><span class="special">&</span> <span class="identifier">y</span> <span class="special">)</span> <span class="special">;</span> <a class="link" href="detailed_semantics.html#reference_operator_compare_greater_or_equal_optional_optional"><span class="inlinemediaobject"><img src="../images/callouts/R.png" alt="R"></span></a>
|
<span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">></span> <span class="keyword">inline</span> <span class="keyword">bool</span> <span class="keyword">operator</span> <span class="special">>=</span> <span class="special">(</span> <span class="identifier">optional</span><span class="special"><</span><span class="identifier">T</span><span class="special">></span> <span class="keyword">const</span><span class="special">&</span> <span class="identifier">x</span><span class="special">,</span> <span class="identifier">optional</span><span class="special"><</span><span class="identifier">T</span><span class="special">></span> <span class="keyword">const</span><span class="special">&</span> <span class="identifier">y</span> <span class="special">)</span> <span class="special">;</span> <a href="detailed_semantics.html#reference_operator_compare_greater_or_equal_optional_optional"><span class="inlinemediaobject"><img src="../images/callouts/R.png" alt="R"></span></a>
|
||||||
|
|
||||||
<span class="comment">// [new in 1.34]
|
<span class="comment">// [new in 1.34]
|
||||||
</span><span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">></span> <span class="keyword">inline</span> <span class="identifier">optional</span><span class="special"><</span><span class="identifier">T</span><span class="special">></span> <span class="identifier">make_optional</span> <span class="special">(</span> <span class="identifier">T</span> <span class="keyword">const</span><span class="special">&</span> <span class="identifier">v</span> <span class="special">)</span> <span class="special">;</span> <a class="link" href="detailed_semantics.html#reference_make_optional_value"><span class="inlinemediaobject"><img src="../images/callouts/R.png" alt="R"></span></a>
|
</span><span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">></span> <span class="keyword">inline</span> <span class="identifier">optional</span><span class="special"><</span><span class="identifier">T</span><span class="special">></span> <span class="identifier">make_optional</span> <span class="special">(</span> <span class="identifier">T</span> <span class="keyword">const</span><span class="special">&</span> <span class="identifier">v</span> <span class="special">)</span> <span class="special">;</span> <a href="detailed_semantics.html#reference_make_optional_value"><span class="inlinemediaobject"><img src="../images/callouts/R.png" alt="R"></span></a>
|
||||||
|
|
||||||
<span class="comment">// [new in 1.34]
|
<span class="comment">// [new in 1.34]
|
||||||
</span><span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">></span> <span class="keyword">inline</span> <span class="identifier">optional</span><span class="special"><</span><span class="identifier">T</span><span class="special">></span> <span class="identifier">make_optional</span> <span class="special">(</span> <span class="keyword">bool</span> <span class="identifier">condition</span><span class="special">,</span> <span class="identifier">T</span> <span class="keyword">const</span><span class="special">&</span> <span class="identifier">v</span> <span class="special">)</span> <span class="special">;</span> <a class="link" href="detailed_semantics.html#reference_make_optional_bool_value"><span class="inlinemediaobject"><img src="../images/callouts/R.png" alt="R"></span></a>
|
</span><span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">></span> <span class="keyword">inline</span> <span class="identifier">optional</span><span class="special"><</span><span class="identifier">T</span><span class="special">></span> <span class="identifier">make_optional</span> <span class="special">(</span> <span class="keyword">bool</span> <span class="identifier">condition</span><span class="special">,</span> <span class="identifier">T</span> <span class="keyword">const</span><span class="special">&</span> <span class="identifier">v</span> <span class="special">)</span> <span class="special">;</span> <a href="detailed_semantics.html#reference_make_optional_bool_value"><span class="inlinemediaobject"><img src="../images/callouts/R.png" alt="R"></span></a>
|
||||||
|
|
||||||
<span class="comment">// [new in 1.34]
|
<span class="comment">// [new in 1.34]
|
||||||
</span><span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">></span> <span class="keyword">inline</span> <span class="identifier">T</span> <span class="keyword">const</span><span class="special">&</span> <span class="identifier">get_optional_value_or</span> <span class="special">(</span> <span class="identifier">optional</span><span class="special"><</span><span class="identifier">T</span><span class="special">></span> <span class="keyword">const</span><span class="special">&</span> <span class="identifier">opt</span><span class="special">,</span> <span class="identifier">T</span> <span class="keyword">const</span><span class="special">&</span> <span class="keyword">default</span> <span class="special">)</span> <span class="special">;</span> <a class="link" href="detailed_semantics.html#reference_optional_get_value_or_value"><span class="inlinemediaobject"><img src="../images/callouts/R.png" alt="R"></span></a>
|
</span><span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">></span> <span class="keyword">inline</span> <span class="identifier">T</span> <span class="keyword">const</span><span class="special">&</span> <span class="identifier">get_optional_value_or</span> <span class="special">(</span> <span class="identifier">optional</span><span class="special"><</span><span class="identifier">T</span><span class="special">></span> <span class="keyword">const</span><span class="special">&</span> <span class="identifier">opt</span><span class="special">,</span> <span class="identifier">T</span> <span class="keyword">const</span><span class="special">&</span> <span class="keyword">default</span> <span class="special">)</span> <span class="special">;</span> <a href="detailed_semantics.html#reference_optional_get_value_or_value"><span class="inlinemediaobject"><img src="../images/callouts/R.png" alt="R"></span></a>
|
||||||
|
|
||||||
<span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">></span> <span class="keyword">inline</span> <span class="identifier">T</span> <span class="keyword">const</span><span class="special">&</span> <span class="identifier">get</span> <span class="special">(</span> <span class="identifier">optional</span><span class="special"><</span><span class="identifier">T</span><span class="special">></span> <span class="keyword">const</span><span class="special">&</span> <span class="identifier">opt</span> <span class="special">)</span> <span class="special">;</span> <a class="link" href="detailed_semantics.html#reference_optional_get"><span class="inlinemediaobject"><img src="../images/callouts/R.png" alt="R"></span></a>
|
<span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">></span> <span class="keyword">inline</span> <span class="identifier">T</span> <span class="keyword">const</span><span class="special">&</span> <span class="identifier">get</span> <span class="special">(</span> <span class="identifier">optional</span><span class="special"><</span><span class="identifier">T</span><span class="special">></span> <span class="keyword">const</span><span class="special">&</span> <span class="identifier">opt</span> <span class="special">)</span> <span class="special">;</span> <a href="detailed_semantics.html#reference_optional_get"><span class="inlinemediaobject"><img src="../images/callouts/R.png" alt="R"></span></a>
|
||||||
|
|
||||||
<span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">></span> <span class="keyword">inline</span> <span class="identifier">T</span><span class="special">&</span> <span class="identifier">get</span> <span class="special">(</span> <span class="identifier">optional</span><span class="special"><</span><span class="identifier">T</span><span class="special">></span> <span class="special">&</span> <span class="identifier">opt</span> <span class="special">)</span> <span class="special">;</span> <a class="link" href="detailed_semantics.html#reference_optional_get"><span class="inlinemediaobject"><img src="../images/callouts/R.png" alt="R"></span></a>
|
<span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">></span> <span class="keyword">inline</span> <span class="identifier">T</span><span class="special">&</span> <span class="identifier">get</span> <span class="special">(</span> <span class="identifier">optional</span><span class="special"><</span><span class="identifier">T</span><span class="special">></span> <span class="special">&</span> <span class="identifier">opt</span> <span class="special">)</span> <span class="special">;</span> <a href="detailed_semantics.html#reference_optional_get"><span class="inlinemediaobject"><img src="../images/callouts/R.png" alt="R"></span></a>
|
||||||
|
|
||||||
<span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">></span> <span class="keyword">inline</span> <span class="identifier">T</span> <span class="keyword">const</span><span class="special">*</span> <span class="identifier">get</span> <span class="special">(</span> <span class="identifier">optional</span><span class="special"><</span><span class="identifier">T</span><span class="special">></span> <span class="keyword">const</span><span class="special">*</span> <span class="identifier">opt</span> <span class="special">)</span> <span class="special">;</span> <a class="link" href="detailed_semantics.html#reference_optional_get"><span class="inlinemediaobject"><img src="../images/callouts/R.png" alt="R"></span></a>
|
<span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">></span> <span class="keyword">inline</span> <span class="identifier">T</span> <span class="keyword">const</span><span class="special">*</span> <span class="identifier">get</span> <span class="special">(</span> <span class="identifier">optional</span><span class="special"><</span><span class="identifier">T</span><span class="special">></span> <span class="keyword">const</span><span class="special">*</span> <span class="identifier">opt</span> <span class="special">)</span> <span class="special">;</span> <a href="detailed_semantics.html#reference_optional_get"><span class="inlinemediaobject"><img src="../images/callouts/R.png" alt="R"></span></a>
|
||||||
|
|
||||||
<span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">></span> <span class="keyword">inline</span> <span class="identifier">T</span><span class="special">*</span> <span class="identifier">get</span> <span class="special">(</span> <span class="identifier">optional</span><span class="special"><</span><span class="identifier">T</span><span class="special">>*</span> <span class="identifier">opt</span> <span class="special">)</span> <span class="special">;</span> <a class="link" href="detailed_semantics.html#reference_optional_get"><span class="inlinemediaobject"><img src="../images/callouts/R.png" alt="R"></span></a>
|
<span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">></span> <span class="keyword">inline</span> <span class="identifier">T</span><span class="special">*</span> <span class="identifier">get</span> <span class="special">(</span> <span class="identifier">optional</span><span class="special"><</span><span class="identifier">T</span><span class="special">>*</span> <span class="identifier">opt</span> <span class="special">)</span> <span class="special">;</span> <a href="detailed_semantics.html#reference_optional_get"><span class="inlinemediaobject"><img src="../images/callouts/R.png" alt="R"></span></a>
|
||||||
|
|
||||||
<span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">></span> <span class="keyword">inline</span> <span class="identifier">T</span> <span class="keyword">const</span><span class="special">*</span> <span class="identifier">get_pointer</span> <span class="special">(</span> <span class="identifier">optional</span><span class="special"><</span><span class="identifier">T</span><span class="special">></span> <span class="keyword">const</span><span class="special">&</span> <span class="identifier">opt</span> <span class="special">)</span> <span class="special">;</span> <a class="link" href="detailed_semantics.html#reference_optional_get_ptr"><span class="inlinemediaobject"><img src="../images/callouts/R.png" alt="R"></span></a>
|
<span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">></span> <span class="keyword">inline</span> <span class="identifier">T</span> <span class="keyword">const</span><span class="special">*</span> <span class="identifier">get_pointer</span> <span class="special">(</span> <span class="identifier">optional</span><span class="special"><</span><span class="identifier">T</span><span class="special">></span> <span class="keyword">const</span><span class="special">&</span> <span class="identifier">opt</span> <span class="special">)</span> <span class="special">;</span> <a href="detailed_semantics.html#reference_optional_get_ptr"><span class="inlinemediaobject"><img src="../images/callouts/R.png" alt="R"></span></a>
|
||||||
|
|
||||||
<span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">></span> <span class="keyword">inline</span> <span class="identifier">T</span><span class="special">*</span> <span class="identifier">get_pointer</span> <span class="special">(</span> <span class="identifier">optional</span><span class="special"><</span><span class="identifier">T</span><span class="special">></span> <span class="special">&</span> <span class="identifier">opt</span> <span class="special">)</span> <span class="special">;</span> <a class="link" href="detailed_semantics.html#reference_optional_get_ptr"><span class="inlinemediaobject"><img src="../images/callouts/R.png" alt="R"></span></a>
|
<span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">></span> <span class="keyword">inline</span> <span class="identifier">T</span><span class="special">*</span> <span class="identifier">get_pointer</span> <span class="special">(</span> <span class="identifier">optional</span><span class="special"><</span><span class="identifier">T</span><span class="special">></span> <span class="special">&</span> <span class="identifier">opt</span> <span class="special">)</span> <span class="special">;</span> <a href="detailed_semantics.html#reference_optional_get_ptr"><span class="inlinemediaobject"><img src="../images/callouts/R.png" alt="R"></span></a>
|
||||||
|
|
||||||
<span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">></span> <span class="keyword">inline</span> <span class="keyword">void</span> <span class="identifier">swap</span><span class="special">(</span> <span class="identifier">optional</span><span class="special"><</span><span class="identifier">T</span><span class="special">>&</span> <span class="identifier">x</span><span class="special">,</span> <span class="identifier">optional</span><span class="special"><</span><span class="identifier">T</span><span class="special">>&</span> <span class="identifier">y</span> <span class="special">)</span> <span class="special">;</span> <a class="link" href="detailed_semantics.html#reference_swap_optional_optional"><span class="inlinemediaobject"><img src="../images/callouts/R.png" alt="R"></span></a>
|
<span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">></span> <span class="keyword">inline</span> <span class="keyword">void</span> <span class="identifier">swap</span><span class="special">(</span> <span class="identifier">optional</span><span class="special"><</span><span class="identifier">T</span><span class="special">>&</span> <span class="identifier">x</span><span class="special">,</span> <span class="identifier">optional</span><span class="special"><</span><span class="identifier">T</span><span class="special">>&</span> <span class="identifier">y</span> <span class="special">)</span> <span class="special">;</span> <a href="detailed_semantics.html#reference_swap_optional_optional"><span class="inlinemediaobject"><img src="../images/callouts/R.png" alt="R"></span></a>
|
||||||
|
|
||||||
<span class="special">}</span> <span class="comment">// namespace boost
|
<span class="special">}</span> <span class="comment">// namespace boost
|
||||||
</span></pre>
|
</span></pre>
|
||||||
</div>
|
</div>
|
||||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||||||
<td align="left"></td>
|
<td align="left"></td>
|
||||||
<td align="right"><div class="copyright-footer">Copyright © 2003-2007 Fernando Luis Cacciola Carballal<p>
|
<td align="right"><div class="copyright-footer">Copyright <EFBFBD> 2003 -2007 Fernando Luis Cacciola Carballal<p>
|
||||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||||
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
|
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
|
||||||
</p>
|
</p>
|
||||||
@ -146,7 +145,7 @@
|
|||||||
</tr></table>
|
</tr></table>
|
||||||
<hr>
|
<hr>
|
||||||
<div class="spirit-nav">
|
<div class="spirit-nav">
|
||||||
<a accesskey="p" href="development.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><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="detailed_semantics.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
|
<a accesskey="p" href="development.html"><img src="../../../../../doc/html/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/html/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/html/images/home.png" alt="Home"></a><a accesskey="n" href="detailed_semantics.html"><img src="../../../../../doc/html/images/next.png" alt="Next"></a>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
@ -1,30 +1,31 @@
|
|||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
||||||
<title>Type requirements</title>
|
<title>Type requirements</title>
|
||||||
<link rel="stylesheet" href="../boostbook.css" type="text/css">
|
<link rel="stylesheet" href="../boostbook.css" type="text/css">
|
||||||
<meta name="generator" content="DocBook XSL Stylesheets V1.75.2">
|
<meta name="generator" content="DocBook XSL Stylesheets V1.70.1">
|
||||||
<link rel="home" href="../index.html" title="Chapter 1. Boost.Optional">
|
<link rel="start" href="../index.html" title="Chapter<EFBFBD>1.<2E>Boost.Optional">
|
||||||
<link rel="up" href="../index.html" title="Chapter 1. Boost.Optional">
|
<link rel="up" href="../index.html" title="Chapter<EFBFBD>1.<2E>Boost.Optional">
|
||||||
<link rel="prev" href="exception_safety_guarantees.html" title="Exception Safety Guarantees">
|
<link rel="prev" href="exception_safety_guarantees.html" title="Exception Safety
|
||||||
|
Guarantees">
|
||||||
<link rel="next" href="implementation_notes.html" title="Implementation Notes">
|
<link rel="next" href="implementation_notes.html" title="Implementation Notes">
|
||||||
</head>
|
</head>
|
||||||
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
||||||
<table cellpadding="2" width="100%"><tr>
|
<table cellpadding="2" width="100%"><tr>
|
||||||
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../boost.png"></td>
|
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../boost.png"></td>
|
||||||
<td align="center"><a href="../../../../../index.html">Home</a></td>
|
<td align="center"><a href="../../../../../index.htm">Home</a></td>
|
||||||
<td align="center"><a href="../../../../../libs/libraries.htm">Libraries</a></td>
|
<td align="center"><a href="../../../../libraries.htm">Libraries</a></td>
|
||||||
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
|
<td align="center"><a href="http://www.boost.org/people/people.htm">People</a></td>
|
||||||
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
|
<td align="center"><a href="http://www.boost.org/more/faq.htm">FAQ</a></td>
|
||||||
<td align="center"><a href="../../../../../more/index.htm">More</a></td>
|
<td align="center"><a href="../../../../../more/index.htm">More</a></td>
|
||||||
</tr></table>
|
</tr></table>
|
||||||
<hr>
|
<hr>
|
||||||
<div class="spirit-nav">
|
<div class="spirit-nav">
|
||||||
<a accesskey="p" href="exception_safety_guarantees.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><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="implementation_notes.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
|
<a accesskey="p" href="exception_safety_guarantees.html"><img src="../../../../../doc/html/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/html/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/html/images/home.png" alt="Home"></a><a accesskey="n" href="implementation_notes.html"><img src="../../../../../doc/html/images/next.png" alt="Next"></a>
|
||||||
</div>
|
</div>
|
||||||
<div class="section">
|
<div class="section" lang="en">
|
||||||
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
|
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
|
||||||
<a name="boost_optional.type_requirements"></a><a class="link" href="type_requirements.html" title="Type requirements">Type requirements</a>
|
<a name="boost_optional.type_requirements"></a><a href="type_requirements.html" title="Type requirements">Type requirements</a>
|
||||||
</h2></div></div></div>
|
</h2></div></div></div>
|
||||||
<p>
|
<p>
|
||||||
In general, <code class="computeroutput"><span class="identifier">T</span></code> must be <a href="../../../../utility/CopyConstructible.html" target="_top">Copy Constructible</a> and
|
In general, <code class="computeroutput"><span class="identifier">T</span></code> must be <a href="../../../../utility/CopyConstructible.html" target="_top">Copy Constructible</a> and
|
||||||
@ -39,7 +40,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||||||
<td align="left"></td>
|
<td align="left"></td>
|
||||||
<td align="right"><div class="copyright-footer">Copyright © 2003-2007 Fernando Luis Cacciola Carballal<p>
|
<td align="right"><div class="copyright-footer">Copyright <EFBFBD> 2003 -2007 Fernando Luis Cacciola Carballal<p>
|
||||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||||
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
|
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
|
||||||
</p>
|
</p>
|
||||||
@ -47,7 +48,7 @@
|
|||||||
</tr></table>
|
</tr></table>
|
||||||
<hr>
|
<hr>
|
||||||
<div class="spirit-nav">
|
<div class="spirit-nav">
|
||||||
<a accesskey="p" href="exception_safety_guarantees.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><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="implementation_notes.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
|
<a accesskey="p" href="exception_safety_guarantees.html"><img src="../../../../../doc/html/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/html/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/html/images/home.png" alt="Home"></a><a accesskey="n" href="implementation_notes.html"><img src="../../../../../doc/html/images/next.png" alt="Next"></a>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
@ -1,33 +1,33 @@
|
|||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
||||||
<title>Chapter 1. Boost.Optional</title>
|
<title>Chapter<EFBFBD>1.<2E>Boost.Optional</title>
|
||||||
<link rel="stylesheet" href="boostbook.css" type="text/css">
|
<link rel="stylesheet" href="boostbook.css" type="text/css">
|
||||||
<meta name="generator" content="DocBook XSL Stylesheets V1.75.2">
|
<meta name="generator" content="DocBook XSL Stylesheets V1.70.1">
|
||||||
<link rel="home" href="index.html" title="Chapter 1. Boost.Optional">
|
<link rel="start" href="index.html" title="Chapter<EFBFBD>1.<2E>Boost.Optional">
|
||||||
<link rel="next" href="boost_optional/development.html" title="Development">
|
<link rel="next" href="boost_optional/development.html" title="Development">
|
||||||
</head>
|
</head>
|
||||||
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
||||||
<table cellpadding="2" width="100%"><tr>
|
<table cellpadding="2" width="100%"><tr>
|
||||||
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../boost.png"></td>
|
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../boost.png"></td>
|
||||||
<td align="center"><a href="../../../../index.html">Home</a></td>
|
<td align="center"><a href="../../../../index.htm">Home</a></td>
|
||||||
<td align="center"><a href="../../../../libs/libraries.htm">Libraries</a></td>
|
<td align="center"><a href="../../../libraries.htm">Libraries</a></td>
|
||||||
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
|
<td align="center"><a href="http://www.boost.org/people/people.htm">People</a></td>
|
||||||
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
|
<td align="center"><a href="http://www.boost.org/more/faq.htm">FAQ</a></td>
|
||||||
<td align="center"><a href="../../../../more/index.htm">More</a></td>
|
<td align="center"><a href="../../../../more/index.htm">More</a></td>
|
||||||
</tr></table>
|
</tr></table>
|
||||||
<hr>
|
<hr>
|
||||||
<div class="spirit-nav"><a accesskey="n" href="boost_optional/development.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a></div>
|
<div class="spirit-nav"><a accesskey="n" href="boost_optional/development.html"><img src="../../../../doc/html/images/next.png" alt="Next"></a></div>
|
||||||
<div class="chapter">
|
<div class="chapter" lang="en">
|
||||||
<div class="titlepage"><div>
|
<div class="titlepage"><div>
|
||||||
<div><h2 class="title">
|
<div><h2 class="title">
|
||||||
<a name="optional"></a>Chapter 1. Boost.Optional</h2></div>
|
<a name="optional"></a>Chapter<EFBFBD>1.<2E>Boost.Optional</h2></div>
|
||||||
<div><div class="author"><h3 class="author">
|
<div><div class="author"><h3 class="author">
|
||||||
<span class="firstname">Fernando Luis</span> <span class="surname">Cacciola Carballal</span>
|
<span class="firstname">Fernando Luis</span> <span class="surname">Cacciola Carballal</span>
|
||||||
</h3></div></div>
|
</h3></div></div>
|
||||||
<div><p class="copyright">Copyright © 2003-2007 Fernando Luis Cacciola Carballal</p></div>
|
<div><p class="copyright">Copyright <EFBFBD> 2003 -2007 Fernando Luis Cacciola Carballal</p></div>
|
||||||
<div><div class="legalnotice">
|
<div><div class="legalnotice">
|
||||||
<a name="id2833979"></a><p>
|
<a name="id2604939"></a><p>
|
||||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||||
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
|
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
|
||||||
</p>
|
</p>
|
||||||
@ -71,24 +71,25 @@
|
|||||||
<dt><span class="section"><a href="boost_optional/acknowledgments.html">Acknowledgments</a></span></dt>
|
<dt><span class="section"><a href="boost_optional/acknowledgments.html">Acknowledgments</a></span></dt>
|
||||||
</dl>
|
</dl>
|
||||||
</div>
|
</div>
|
||||||
<div class="section">
|
<div class="section" lang="en">
|
||||||
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
|
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
|
||||||
<a name="optional.motivation"></a><a class="link" href="index.html#optional.motivation" title="Motivation">Motivation</a>
|
<a name="optional.motivation"></a><a href="index.html#optional.motivation" title="Motivation">Motivation</a>
|
||||||
</h2></div></div></div>
|
</h2></div></div></div>
|
||||||
<p>
|
<p>
|
||||||
Consider these functions which should return a value but which might not have
|
Consider these functions which should return a value but which might not have
|
||||||
a value to return:
|
a value to return:
|
||||||
</p>
|
</p>
|
||||||
<div class="itemizedlist"><ul class="itemizedlist" type="disc">
|
<div class="itemizedlist"><ul type="disc">
|
||||||
<li class="listitem">
|
<li>
|
||||||
(A) <code class="computeroutput"><span class="keyword">double</span> <span class="identifier">sqrt</span><span class="special">(</span><span class="keyword">double</span> <span class="identifier">n</span> <span class="special">);</span></code>
|
(A) <code class="computeroutput"><span class="keyword">double</span> <span class="identifier">sqrt</span><span class="special">(</span><span class="keyword">double</span> <span class="identifier">n</span>
|
||||||
</li>
|
<span class="special">);</span></code>
|
||||||
<li class="listitem">
|
</li>
|
||||||
(B) <code class="computeroutput"><span class="keyword">char</span> <span class="identifier">get_async_input</span><span class="special">();</span></code>
|
<li>
|
||||||
</li>
|
(B) <code class="computeroutput"><span class="keyword">char</span> <span class="identifier">get_async_input</span><span class="special">();</span></code>
|
||||||
<li class="listitem">
|
</li>
|
||||||
(C) <code class="computeroutput"><span class="identifier">point</span> <span class="identifier">polygon</span><span class="special">::</span><span class="identifier">get_any_point_effectively_inside</span><span class="special">();</span></code>
|
<li>
|
||||||
</li>
|
(C) <code class="computeroutput"><span class="identifier">point</span> <span class="identifier">polygon</span><span class="special">::</span><span class="identifier">get_any_point_effectively_inside</span><span class="special">();</span></code>
|
||||||
|
</li>
|
||||||
</ul></div>
|
</ul></div>
|
||||||
<p>
|
<p>
|
||||||
There are different approaches to the issue of not having a value to return.
|
There are different approaches to the issue of not having a value to return.
|
||||||
@ -141,14 +142,16 @@
|
|||||||
the function would conceptually return. For example, the last two functions
|
the function would conceptually return. For example, the last two functions
|
||||||
could have the following interface:
|
could have the following interface:
|
||||||
</p>
|
</p>
|
||||||
<pre class="programlisting"><span class="identifier">std</span><span class="special">::</span><span class="identifier">pair</span><span class="special"><</span><span class="keyword">char</span><span class="special">,</span><span class="keyword">bool</span><span class="special">></span> <span class="identifier">get_async_input</span><span class="special">();</span>
|
<pre class="programlisting">
|
||||||
|
<span class="identifier">std</span><span class="special">::</span><span class="identifier">pair</span><span class="special"><</span><span class="keyword">char</span><span class="special">,</span><span class="keyword">bool</span><span class="special">></span> <span class="identifier">get_async_input</span><span class="special">();</span>
|
||||||
<span class="identifier">std</span><span class="special">::</span><span class="identifier">pair</span><span class="special"><</span><span class="identifier">point</span><span class="special">,</span><span class="keyword">bool</span><span class="special">></span> <span class="identifier">polygon</span><span class="special">::</span><span class="identifier">get_any_point_effectively_inside</span><span class="special">();</span>
|
<span class="identifier">std</span><span class="special">::</span><span class="identifier">pair</span><span class="special"><</span><span class="identifier">point</span><span class="special">,</span><span class="keyword">bool</span><span class="special">></span> <span class="identifier">polygon</span><span class="special">::</span><span class="identifier">get_any_point_effectively_inside</span><span class="special">();</span>
|
||||||
</pre>
|
</pre>
|
||||||
<p>
|
<p>
|
||||||
These functions use a consistent interface for dealing with possibly nonexistent
|
These functions use a consistent interface for dealing with possibly inexistent
|
||||||
results:
|
results:
|
||||||
</p>
|
</p>
|
||||||
<pre class="programlisting"><span class="identifier">std</span><span class="special">::</span><span class="identifier">pair</span><span class="special"><</span><span class="identifier">point</span><span class="special">,</span><span class="keyword">bool</span><span class="special">></span> <span class="identifier">p</span> <span class="special">=</span> <span class="identifier">poly</span><span class="special">.</span><span class="identifier">get_any_point_effectively_inside</span><span class="special">();</span>
|
<pre class="programlisting">
|
||||||
|
<span class="identifier">std</span><span class="special">::</span><span class="identifier">pair</span><span class="special"><</span><span class="identifier">point</span><span class="special">,</span><span class="keyword">bool</span><span class="special">></span> <span class="identifier">p</span> <span class="special">=</span> <span class="identifier">poly</span><span class="special">.</span><span class="identifier">get_any_point_effectively_inside</span><span class="special">();</span>
|
||||||
<span class="keyword">if</span> <span class="special">(</span> <span class="identifier">p</span><span class="special">.</span><span class="identifier">second</span> <span class="special">)</span>
|
<span class="keyword">if</span> <span class="special">(</span> <span class="identifier">p</span><span class="special">.</span><span class="identifier">second</span> <span class="special">)</span>
|
||||||
<span class="identifier">flood_fill</span><span class="special">(</span><span class="identifier">p</span><span class="special">.</span><span class="identifier">first</span><span class="special">);</span>
|
<span class="identifier">flood_fill</span><span class="special">(</span><span class="identifier">p</span><span class="special">.</span><span class="identifier">first</span><span class="special">);</span>
|
||||||
</pre>
|
</pre>
|
||||||
@ -161,12 +164,20 @@
|
|||||||
Clearly, we need a better idiom.
|
Clearly, we need a better idiom.
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
<p>
|
||||||
|
</p>
|
||||||
|
<a name="optional_refassign"></a><p>
|
||||||
|
</p>
|
||||||
|
<a name="optional_in_place_factories"></a><p>
|
||||||
|
</p>
|
||||||
|
<a name="optional_implementation_notes"></a><p>
|
||||||
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||||||
<td align="left"><p><small>Last revised: April 07, 2011 at 21:02:08 GMT</small></p></td>
|
<td align="left"><p><small>Last revised: February 12, 2008 at 22:47:14 GMT</small></p></td>
|
||||||
<td align="right"><div class="copyright-footer"></div></td>
|
<td align="right"><div class="copyright-footer"></div></td>
|
||||||
</tr></table>
|
</tr></table>
|
||||||
<hr>
|
<hr>
|
||||||
<div class="spirit-nav"><a accesskey="n" href="boost_optional/development.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a></div>
|
<div class="spirit-nav"><a accesskey="n" href="boost_optional/development.html"><img src="../../../../doc/html/images/next.png" alt="Next"></a></div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
@ -10,6 +10,8 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
[#optional_implementation_notes]
|
||||||
|
|
||||||
[section Implementation Notes]
|
[section Implementation Notes]
|
||||||
|
|
||||||
`optional<T>` is currently implemented using a custom aligned storage facility
|
`optional<T>` is currently implemented using a custom aligned storage facility
|
||||||
|
@ -99,7 +99,7 @@ functions could have the following interface:
|
|||||||
std::pair<char,bool> get_async_input();
|
std::pair<char,bool> get_async_input();
|
||||||
std::pair<point,bool> polygon::get_any_point_effectively_inside();
|
std::pair<point,bool> polygon::get_any_point_effectively_inside();
|
||||||
|
|
||||||
These functions use a consistent interface for dealing with possibly nonexistent
|
These functions use a consistent interface for dealing with possibly inexistent
|
||||||
results:
|
results:
|
||||||
|
|
||||||
std::pair<point,bool> p = poly.get_any_point_effectively_inside();
|
std::pair<point,bool> p = poly.get_any_point_effectively_inside();
|
||||||
|
@ -11,8 +11,6 @@
|
|||||||
|
|
||||||
[section Synopsis]
|
[section Synopsis]
|
||||||
|
|
||||||
```// In Header: <`[@boost:/boost/optional/optional.hpp boost/optional/optional.hpp]'''<phrase role="comment">></phrase>'''``
|
|
||||||
|
|
||||||
namespace boost {
|
namespace boost {
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
@ -47,9 +45,9 @@
|
|||||||
|
|
||||||
template<class U> optional& operator = ( optional<U> const& rhs ) ; ``[link reference_optional_operator_equal_other_optional __GO_TO__]``
|
template<class U> optional& operator = ( optional<U> const& rhs ) ; ``[link reference_optional_operator_equal_other_optional __GO_TO__]``
|
||||||
|
|
||||||
template<class InPlaceFactory> optional& operator = ( InPlaceFactory const& f ) ; ``[link reference_optional_operator_equal_factory __GO_TO__]``
|
template<class InPlaceFactory> optional& operator = ( InPlaceFactory const& f ) ; ``[/[link reference_optional_operator_equal_factory __GO_TO__]]``
|
||||||
|
|
||||||
template<class TypedInPlaceFactory> optional& operator = ( TypedInPlaceFactory const& f ) ; ``[link reference_optional_operator_equal_factory __GO_TO__]``
|
template<class TypedInPlaceFactory> optional& operator = ( TypedInPlaceFactory const& f ) ; ``[/[link reference_optional_operator_equal_factory __GO_TO__]]``
|
||||||
|
|
||||||
T const& get() const ; ``[link reference_optional_get __GO_TO__]``
|
T const& get() const ; ``[link reference_optional_get __GO_TO__]``
|
||||||
T& get() ; ``[link reference_optional_get __GO_TO__]``
|
T& get() ; ``[link reference_optional_get __GO_TO__]``
|
||||||
@ -234,7 +232,7 @@ __SPACE__
|
|||||||
|
|
||||||
* otherwise, same as:
|
* otherwise, same as:
|
||||||
|
|
||||||
[: `optional<T `['(not a ref)]`>::optional()`]
|
[: `optional<T ['(not a ref)]>::optional()`]
|
||||||
[: `optional<T&> ::optional()`]
|
[: `optional<T&> ::optional()`]
|
||||||
|
|
||||||
__SPACE__
|
__SPACE__
|
||||||
@ -333,7 +331,7 @@ factory.
|
|||||||
* [*Postconditions: ] `*this` is [_initialized] and its value is ['directly given]
|
* [*Postconditions: ] `*this` is [_initialized] and its value is ['directly given]
|
||||||
from the factory `f` (i.e., the value [_is not copied]).
|
from the factory `f` (i.e., the value [_is not copied]).
|
||||||
* [*Throws:] Whatever the `T` constructor called by the factory throws.
|
* [*Throws:] Whatever the `T` constructor called by the factory throws.
|
||||||
* [*Notes:] See [link boost_optional.in_place_factories In-Place Factories]
|
* [*Notes:] See [link optional_in_place_factories In-Place Factories]
|
||||||
* [*Exception Safety:] Exceptions can only be thrown during the call to
|
* [*Exception Safety:] Exceptions can only be thrown during the call to
|
||||||
the `T` constructor used by the factory; in that case, this constructor has
|
the `T` constructor used by the factory; in that case, this constructor has
|
||||||
no effect.
|
no effect.
|
||||||
@ -381,13 +379,13 @@ assert ( *opt == y ) ;
|
|||||||
|
|
||||||
__SPACE__
|
__SPACE__
|
||||||
|
|
||||||
[: `optional<T&>& optional<T&>::operator= ( T& rhs ) ;`]
|
[: `optional<T&>& optional<T&>::operator= ( T& const& rhs ) ;`]
|
||||||
|
|
||||||
* [*Effect:] (Re)binds the wrapped reference.
|
* [*Effect:] (Re)binds thee wrapped reference.
|
||||||
* [*Postconditions: ] `*this` is initialized and it references the same
|
* [*Postconditions: ] `*this` is initialized and it references the same
|
||||||
object referenced by `rhs`.
|
object referenced by `rhs`.
|
||||||
* [*Notes:] If `*this` was initialized, is is ['rebound] to the new object.
|
* [*Notes:] If `*this` was initialized, is is ['rebound] to the new object.
|
||||||
See [link boost_optional.rebinding_semantics_for_assignment_of_optional_references here] for details on this behavior.
|
See [link optional_refassign here] for details on this behavior.
|
||||||
* [*Example:]
|
* [*Example:]
|
||||||
``
|
``
|
||||||
int a = 1 ;
|
int a = 1 ;
|
||||||
@ -446,7 +444,7 @@ __SPACE__
|
|||||||
references the same object referenced by `*rhs`; otherwise, `*this` is
|
references the same object referenced by `*rhs`; otherwise, `*this` is
|
||||||
uninitialized (and references no object).
|
uninitialized (and references no object).
|
||||||
* [*Notes:] If `*this` was initialized and so is *rhs, this is is ['rebound] to
|
* [*Notes:] If `*this` was initialized and so is *rhs, this is is ['rebound] to
|
||||||
the new object. See [link boost_optional.rebinding_semantics_for_assignment_of_optional_references here] for details on this behavior.
|
the new object. See [link optional_refassign here] for details on this behavior.
|
||||||
* [*Example:]
|
* [*Example:]
|
||||||
``
|
``
|
||||||
int a = 1 ;
|
int a = 1 ;
|
||||||
@ -502,23 +500,6 @@ assert ( *opt1 == static_cast<U>(v) ) ;
|
|||||||
|
|
||||||
__SPACE__
|
__SPACE__
|
||||||
|
|
||||||
[#reference_optional_operator_equal_factory]
|
|
||||||
|
|
||||||
[: `template<InPlaceFactory> optional<T>& optional<T` ['(not a ref)]`>::operator=( InPlaceFactory const& f );`]
|
|
||||||
[: `template<TypedInPlaceFactory> optional<T>& optional<T` ['(not a ref)]`>::operator=( TypedInPlaceFactory const& f );`]
|
|
||||||
|
|
||||||
* [*Effect:] Assigns an `optional` with a value of `T` obtained from the
|
|
||||||
factory.
|
|
||||||
* [*Postconditions: ] `*this` is [_initialized] and its value is ['directly given]
|
|
||||||
from the factory `f` (i.e., the value [_is not copied]).
|
|
||||||
* [*Throws:] Whatever the `T` constructor called by the factory throws.
|
|
||||||
* [*Notes:] See [link boost_optional.in_place_factories In-Place Factories]
|
|
||||||
* [*Exception Safety:] Exceptions can only be thrown during the call to
|
|
||||||
the `T` constructor used by the factory; in that case, the `optional` object
|
|
||||||
will be reset to be ['uninitialized].
|
|
||||||
|
|
||||||
__SPACE__
|
|
||||||
|
|
||||||
[#reference_optional_reset_value]
|
[#reference_optional_reset_value]
|
||||||
|
|
||||||
[: `void optional<T` ['(not a ref)]`>::reset( T const& v ) ;`]
|
[: `void optional<T` ['(not a ref)]`>::reset( T const& v ) ;`]
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
|
|
||||||
[section Optional references]
|
[section Optional references]
|
||||||
|
|
||||||
This library allows the template parameter `T` to be of reference type:
|
This library allows the template parameter `T` to be of reference type:
|
||||||
@ -23,6 +23,8 @@ rather than the reference itself.
|
|||||||
|
|
||||||
[endsect]
|
[endsect]
|
||||||
|
|
||||||
|
[#optional_refassign]
|
||||||
|
|
||||||
[section Rebinding semantics for assignment of optional references]
|
[section Rebinding semantics for assignment of optional references]
|
||||||
|
|
||||||
If you assign to an ['uninitialized ] `optional<T&>` the effect is to bind (for
|
If you assign to an ['uninitialized ] `optional<T&>` the effect is to bind (for
|
||||||
@ -37,7 +39,7 @@ the first time) to the object. Clearly, there is no other choice.
|
|||||||
assert(x==2);
|
assert(x==2);
|
||||||
|
|
||||||
If you assign to a bare C++ reference, the assignment is forwarded to the
|
If you assign to a bare C++ reference, the assignment is forwarded to the
|
||||||
referenced object; its value changes but the reference is never rebound.
|
referenced object; it's value changes but the reference is never rebound.
|
||||||
|
|
||||||
int a = 1 ;
|
int a = 1 ;
|
||||||
int& ra = a ;
|
int& ra = a ;
|
||||||
@ -95,21 +97,23 @@ use Optional's assignment without explicitly handling the previous
|
|||||||
initialization state unless your code is capable of functioning whether
|
initialization state unless your code is capable of functioning whether
|
||||||
after the assignment, `a` aliases the same object as `b` or not.
|
after the assignment, `a` aliases the same object as `b` or not.
|
||||||
|
|
||||||
That is, you would have to discriminate in order to be consistent.
|
That is, you would have to discriminate in order to be consistency.
|
||||||
|
|
||||||
If in your code rebinding to another object is not an option, then it is very
|
If in your code rebinding to another object is not an option, then is very
|
||||||
likely that binding for the first time isn't either. In such case, assignment
|
likely that binding for the fist time isn't either. In such case, assignment
|
||||||
to an ['uninitialized ] `optional<T&>` shall be prohibited. It is quite possible
|
to an ['uninitialized ] `optional<T&>` shall be prohibited. It is quite possible
|
||||||
that in such a scenario it is a precondition that the lvalue must be already
|
that in such scenario the precondition that the lvalue must be already
|
||||||
initialized. If it isn't, then binding for the first time is OK
|
initialized exist. If it doesn't, then binding for the first time is OK
|
||||||
while rebinding is not which is IMO very unlikely.
|
while rebinding is not which is IMO very unlikely.
|
||||||
In such a scenario, you can assign the value itself directly, as in:
|
In such scenario, you can assign the value itself directly, as in:
|
||||||
|
|
||||||
assert(!!opt);
|
assert(!!opt);
|
||||||
*opt=value;
|
*opt=value;
|
||||||
|
|
||||||
[endsect]
|
[endsect]
|
||||||
|
|
||||||
|
[#optional_in_place_factories]
|
||||||
|
|
||||||
[section In-Place Factories]
|
[section In-Place Factories]
|
||||||
|
|
||||||
One of the typical problems with wrappers and containers is that their
|
One of the typical problems with wrappers and containers is that their
|
||||||
@ -201,7 +205,7 @@ A wrapper class aware of this can use it as:
|
|||||||
{
|
{
|
||||||
// Wrapped object constructed in-place via a TypedInPlaceFactory.
|
// Wrapped object constructed in-place via a TypedInPlaceFactory.
|
||||||
// No temporary created.
|
// No temporary created.
|
||||||
W ( TypedInPlaceFactory2<X,int,std::string>(123,"hello")) ;
|
W ( TypedInPlaceFactory2<X,int,std::string&rt(123,"hello")) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
The factories are divided in two groups:
|
The factories are divided in two groups:
|
||||||
@ -284,7 +288,7 @@ instead, it won't compile).
|
|||||||
|
|
||||||
[section Exception Safety Guarantees]
|
[section Exception Safety Guarantees]
|
||||||
|
|
||||||
Because of the current implementation (see [link boost_optional.implementation_notes Implementation Notes]), all of the assignment methods:
|
Because of the current implementation (see [link optional_implementation_notes Implementation Notes]), all of the assignment methods:
|
||||||
|
|
||||||
* `optional<T>::operator= ( optional<T> const& )`
|
* `optional<T>::operator= ( optional<T> const& )`
|
||||||
* `optional<T>::operator= ( T const& )`
|
* `optional<T>::operator= ( T const& )`
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
// http://www.boost.org/LICENSE_1_0.txt)
|
// http://www.boost.org/LICENSE_1_0.txt)
|
||||||
//
|
//
|
||||||
// See http://www.boost.org/libs/optional for documentation.
|
// See http://www.boost.org/lib/optional for documentation.
|
||||||
//
|
//
|
||||||
// You are welcome to contact the author at:
|
// You are welcome to contact the author at:
|
||||||
// fernando_cacciola@hotmail.com
|
// fernando_cacciola@hotmail.com
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
|
|
||||||
namespace boost {
|
namespace boost {
|
||||||
|
|
||||||
none_t const none = (static_cast<none_t>(0)) ;
|
none_t const none = ((none_t)0) ;
|
||||||
|
|
||||||
} // namespace boost
|
} // namespace boost
|
||||||
|
|
||||||
|
@ -4,39 +4,37 @@
|
|||||||
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
// http://www.boost.org/LICENSE_1_0.txt)
|
// http://www.boost.org/LICENSE_1_0.txt)
|
||||||
//
|
//
|
||||||
// See http://www.boost.org/libs/optional for documentation.
|
// See http://www.boost.org/lib/optional for documentation.
|
||||||
//
|
//
|
||||||
// You are welcome to contact the author at:
|
// You are welcome to contact the author at:
|
||||||
// fernando_cacciola@hotmail.com
|
// fernando_cacciola@hotmail.com
|
||||||
//
|
//
|
||||||
// Revisions:
|
// Revisions:
|
||||||
// 27 Apr 2008 (improved swap) Fernando Cacciola, Niels Dekker, Thorsten Ottosen
|
// 27 Apr 2008 (improved swap) Fernando Cacciola, Niels Dekker, Thorsten Ottosen
|
||||||
//
|
//
|
||||||
#ifndef BOOST_OPTIONAL_OPTIONAL_FLC_19NOV2002_HPP
|
#ifndef BOOST_OPTIONAL_OPTIONAL_FLC_19NOV2002_HPP
|
||||||
#define BOOST_OPTIONAL_OPTIONAL_FLC_19NOV2002_HPP
|
#define BOOST_OPTIONAL_OPTIONAL_FLC_19NOV2002_HPP
|
||||||
|
|
||||||
#include <new>
|
#include<new>
|
||||||
#include <algorithm>
|
#include<algorithm>
|
||||||
|
|
||||||
#include <boost/config.hpp>
|
#include "boost/config.hpp"
|
||||||
#include <boost/assert.hpp>
|
#include "boost/assert.hpp"
|
||||||
#include <boost/type.hpp>
|
#include "boost/type.hpp"
|
||||||
#include <boost/type_traits/alignment_of.hpp>
|
#include "boost/type_traits/alignment_of.hpp"
|
||||||
#include <boost/type_traits/has_nothrow_constructor.hpp>
|
#include "boost/type_traits/has_nothrow_constructor.hpp"
|
||||||
#include <boost/type_traits/type_with_alignment.hpp>
|
#include "boost/type_traits/type_with_alignment.hpp"
|
||||||
#include <boost/type_traits/remove_reference.hpp>
|
#include "boost/type_traits/remove_reference.hpp"
|
||||||
#include <boost/type_traits/is_reference.hpp>
|
#include "boost/type_traits/is_reference.hpp"
|
||||||
#include <boost/mpl/if.hpp>
|
#include "boost/mpl/if.hpp"
|
||||||
#include <boost/mpl/bool.hpp>
|
#include "boost/mpl/bool.hpp"
|
||||||
#include <boost/mpl/not.hpp>
|
#include "boost/mpl/not.hpp"
|
||||||
#include <boost/detail/reference_content.hpp>
|
#include "boost/detail/reference_content.hpp"
|
||||||
#include <boost/none.hpp>
|
#include "boost/none.hpp"
|
||||||
#include <boost/utility/swap.hpp>
|
#include "boost/utility/compare_pointees.hpp"
|
||||||
#include <boost/utility/addressof.hpp>
|
#include "boost/utility/in_place_factory.hpp"
|
||||||
#include <boost/utility/compare_pointees.hpp>
|
|
||||||
#include <boost/utility/in_place_factory.hpp>
|
|
||||||
|
|
||||||
#include <boost/optional/optional_fwd.hpp>
|
#include "boost/optional/optional_fwd.hpp"
|
||||||
|
|
||||||
#if BOOST_WORKAROUND(BOOST_MSVC, == 1200)
|
#if BOOST_WORKAROUND(BOOST_MSVC, == 1200)
|
||||||
// VC6.0 has the following bug:
|
// VC6.0 has the following bug:
|
||||||
@ -83,15 +81,6 @@
|
|||||||
#define BOOST_OPTIONAL_WEAK_OVERLOAD_RESOLUTION
|
#define BOOST_OPTIONAL_WEAK_OVERLOAD_RESOLUTION
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) > 302 \
|
|
||||||
&& !defined(__INTEL_COMPILER)
|
|
||||||
// GCC since 3.3 has may_alias attribute that helps to alleviate optimizer issues with
|
|
||||||
// regard to violation of the strict aliasing rules. The optional< T > storage type is marked
|
|
||||||
// with this attribute in order to let the compiler know that it will alias objects of type T
|
|
||||||
// and silence compilation warnings.
|
|
||||||
#define BOOST_OPTIONAL_DETAIL_USE_ATTRIBUTE_MAY_ALIAS
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Daniel Wallin discovered that bind/apply.hpp badly interacts with the apply<>
|
// Daniel Wallin discovered that bind/apply.hpp badly interacts with the apply<>
|
||||||
// member template of a factory as used in the optional<> implementation.
|
// member template of a factory as used in the optional<> implementation.
|
||||||
// He proposed this simple fix which is to move the call to apply<> outside
|
// He proposed this simple fix which is to move the call to apply<> outside
|
||||||
@ -99,7 +88,7 @@
|
|||||||
namespace boost_optional_detail
|
namespace boost_optional_detail
|
||||||
{
|
{
|
||||||
template <class T, class Factory>
|
template <class T, class Factory>
|
||||||
inline void construct(Factory const& factory, void* address)
|
void construct(Factory const& factory, void* address)
|
||||||
{
|
{
|
||||||
factory.BOOST_NESTED_TEMPLATE apply<T>(address);
|
factory.BOOST_NESTED_TEMPLATE apply<T>(address);
|
||||||
}
|
}
|
||||||
@ -111,9 +100,6 @@ namespace boost {
|
|||||||
class in_place_factory_base ;
|
class in_place_factory_base ;
|
||||||
class typed_in_place_factory_base ;
|
class typed_in_place_factory_base ;
|
||||||
|
|
||||||
// This forward is needed to refer to namespace scope swap from the member swap
|
|
||||||
template<class T> void swap ( optional<T>& x, optional<T>& y );
|
|
||||||
|
|
||||||
namespace optional_detail {
|
namespace optional_detail {
|
||||||
|
|
||||||
// This local class is used instead of that in "aligned_storage.hpp"
|
// This local class is used instead of that in "aligned_storage.hpp"
|
||||||
@ -124,12 +110,7 @@ template <class T>
|
|||||||
class aligned_storage
|
class aligned_storage
|
||||||
{
|
{
|
||||||
// Borland ICEs if unnamed unions are used for this!
|
// Borland ICEs if unnamed unions are used for this!
|
||||||
union
|
union dummy_u
|
||||||
// This works around GCC warnings about breaking strict aliasing rules when casting storage address to T*
|
|
||||||
#if defined(BOOST_OPTIONAL_DETAIL_USE_ATTRIBUTE_MAY_ALIAS)
|
|
||||||
__attribute__((may_alias))
|
|
||||||
#endif
|
|
||||||
dummy_u
|
|
||||||
{
|
{
|
||||||
char data[ sizeof(T) ];
|
char data[ sizeof(T) ];
|
||||||
BOOST_DEDUCED_TYPENAME type_with_alignment<
|
BOOST_DEDUCED_TYPENAME type_with_alignment<
|
||||||
@ -138,13 +119,8 @@ class aligned_storage
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
#if defined(BOOST_OPTIONAL_DETAIL_USE_ATTRIBUTE_MAY_ALIAS)
|
void const* address() const { return &dummy_.data[0]; }
|
||||||
void const* address() const { return &dummy_; }
|
void * address() { return &dummy_.data[0]; }
|
||||||
void * address() { return &dummy_; }
|
|
||||||
#else
|
|
||||||
void const* address() const { return dummy_.data; }
|
|
||||||
void * address() { return dummy_.data; }
|
|
||||||
#endif
|
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
@ -178,7 +154,7 @@ class optional_base : public optional_tag
|
|||||||
typedef
|
typedef
|
||||||
#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
|
#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
|
||||||
BOOST_DEDUCED_TYPENAME
|
BOOST_DEDUCED_TYPENAME
|
||||||
#endif
|
#endif
|
||||||
::boost::detail::make_reference_content<T>::type internal_type ;
|
::boost::detail::make_reference_content<T>::type internal_type ;
|
||||||
|
|
||||||
typedef aligned_storage<internal_type> storage_type ;
|
typedef aligned_storage<internal_type> storage_type ;
|
||||||
@ -197,10 +173,8 @@ class optional_base : public optional_tag
|
|||||||
|
|
||||||
typedef BOOST_DEDUCED_TYPENAME is_reference<T>::type is_reference_predicate ;
|
typedef BOOST_DEDUCED_TYPENAME is_reference<T>::type is_reference_predicate ;
|
||||||
|
|
||||||
public:
|
|
||||||
typedef BOOST_DEDUCED_TYPENAME mpl::if_<is_reference_predicate,types_when_ref,types_when_not_ref>::type types ;
|
typedef BOOST_DEDUCED_TYPENAME mpl::if_<is_reference_predicate,types_when_ref,types_when_not_ref>::type types ;
|
||||||
|
|
||||||
protected:
|
|
||||||
typedef bool (this_type::*unspecified_bool_type)() const;
|
typedef bool (this_type::*unspecified_bool_type)() const;
|
||||||
|
|
||||||
typedef BOOST_DEDUCED_TYPENAME types::reference_type reference_type ;
|
typedef BOOST_DEDUCED_TYPENAME types::reference_type reference_type ;
|
||||||
@ -229,7 +203,7 @@ class optional_base : public optional_tag
|
|||||||
{
|
{
|
||||||
construct(val);
|
construct(val);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Creates an optional<T> initialized with 'val' IFF cond is true, otherwise creates an uninitialzed optional<T>.
|
// Creates an optional<T> initialized with 'val' IFF cond is true, otherwise creates an uninitialzed optional<T>.
|
||||||
// Can throw if T::T(T const&) does
|
// Can throw if T::T(T const&) does
|
||||||
optional_base ( bool cond, argument_type val )
|
optional_base ( bool cond, argument_type val )
|
||||||
@ -450,22 +424,8 @@ class optional_base : public optional_tag
|
|||||||
private :
|
private :
|
||||||
|
|
||||||
// internal_type can be either T or reference_content<T>
|
// internal_type can be either T or reference_content<T>
|
||||||
#if defined(BOOST_OPTIONAL_DETAIL_USE_ATTRIBUTE_MAY_ALIAS)
|
|
||||||
// This workaround is supposed to silence GCC warnings about broken strict aliasing rules
|
|
||||||
internal_type const* get_object() const
|
|
||||||
{
|
|
||||||
union { void const* ap_pvoid; internal_type const* as_ptype; } caster = { m_storage.address() };
|
|
||||||
return caster.as_ptype;
|
|
||||||
}
|
|
||||||
internal_type * get_object()
|
|
||||||
{
|
|
||||||
union { void* ap_pvoid; internal_type* as_ptype; } caster = { m_storage.address() };
|
|
||||||
return caster.as_ptype;
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
internal_type const* get_object() const { return static_cast<internal_type const*>(m_storage.address()); }
|
internal_type const* get_object() const { return static_cast<internal_type const*>(m_storage.address()); }
|
||||||
internal_type * get_object() { return static_cast<internal_type *> (m_storage.address()); }
|
internal_type * get_object() { return static_cast<internal_type *> (m_storage.address()); }
|
||||||
#endif
|
|
||||||
|
|
||||||
// reference_content<T> lacks an implicit conversion to T&, so the following is needed to obtain a proper reference.
|
// reference_content<T> lacks an implicit conversion to T&, so the following is needed to obtain a proper reference.
|
||||||
reference_const_type dereference( internal_type const* p, is_not_reference_tag ) const { return *p ; }
|
reference_const_type dereference( internal_type const* p, is_not_reference_tag ) const { return *p ; }
|
||||||
@ -556,7 +516,7 @@ class optional : public optional_detail::optional_base<T>
|
|||||||
// Depending on the above some T ctor is called.
|
// Depending on the above some T ctor is called.
|
||||||
// Can throw is the resolved T ctor throws.
|
// Can throw is the resolved T ctor throws.
|
||||||
template<class Expr>
|
template<class Expr>
|
||||||
explicit optional ( Expr const& expr ) : base(expr,boost::addressof(expr)) {}
|
explicit optional ( Expr const& expr ) : base(expr,&expr) {}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Creates a deep copy of another optional<T>
|
// Creates a deep copy of another optional<T>
|
||||||
@ -570,9 +530,9 @@ class optional : public optional_detail::optional_base<T>
|
|||||||
// Assigns from an expression. See corresponding constructor.
|
// Assigns from an expression. See corresponding constructor.
|
||||||
// Basic Guarantee: If the resolved T ctor throws, this is left UNINITIALIZED
|
// Basic Guarantee: If the resolved T ctor throws, this is left UNINITIALIZED
|
||||||
template<class Expr>
|
template<class Expr>
|
||||||
optional& operator= ( Expr const& expr )
|
optional& operator= ( Expr expr )
|
||||||
{
|
{
|
||||||
this->assign_expr(expr,boost::addressof(expr));
|
this->assign_expr(expr,&expr);
|
||||||
return *this ;
|
return *this ;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -619,7 +579,7 @@ class optional : public optional_detail::optional_base<T>
|
|||||||
void swap( optional & arg )
|
void swap( optional & arg )
|
||||||
{
|
{
|
||||||
// allow for Koenig lookup
|
// allow for Koenig lookup
|
||||||
using boost::swap;
|
using boost::swap ;
|
||||||
swap(*this, arg);
|
swap(*this, arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -633,7 +593,7 @@ class optional : public optional_detail::optional_base<T>
|
|||||||
// Returns a copy of the value if this is initialized, 'v' otherwise
|
// Returns a copy of the value if this is initialized, 'v' otherwise
|
||||||
reference_const_type get_value_or ( reference_const_type v ) const { return this->is_initialized() ? get() : v ; }
|
reference_const_type get_value_or ( reference_const_type v ) const { return this->is_initialized() ? get() : v ; }
|
||||||
reference_type get_value_or ( reference_type v ) { return this->is_initialized() ? get() : v ; }
|
reference_type get_value_or ( reference_type v ) { return this->is_initialized() ? get() : v ; }
|
||||||
|
|
||||||
// Returns a pointer to the value if this is initialized, otherwise,
|
// Returns a pointer to the value if this is initialized, otherwise,
|
||||||
// the behaviour is UNDEFINED
|
// the behaviour is UNDEFINED
|
||||||
// No-throw
|
// No-throw
|
||||||
@ -650,22 +610,22 @@ class optional : public optional_detail::optional_base<T>
|
|||||||
// No-throw
|
// No-throw
|
||||||
operator unspecified_bool_type() const { return this->safe_bool() ; }
|
operator unspecified_bool_type() const { return this->safe_bool() ; }
|
||||||
|
|
||||||
// This is provided for those compilers which don't like the conversion to bool
|
// This is provided for those compilers which don't like the conversion to bool
|
||||||
// on some contexts.
|
// on some contexts.
|
||||||
bool operator!() const { return !this->is_initialized() ; }
|
bool operator!() const { return !this->is_initialized() ; }
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
// Returns optional<T>(v)
|
// Returns optional<T>(v)
|
||||||
template<class T>
|
template<class T>
|
||||||
inline
|
inline
|
||||||
optional<T> make_optional ( T const& v )
|
optional<T> make_optional ( T const& v )
|
||||||
{
|
{
|
||||||
return optional<T>(v);
|
return optional<T>(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns optional<T>(cond,v)
|
// Returns optional<T>(cond,v)
|
||||||
template<class T>
|
template<class T>
|
||||||
inline
|
inline
|
||||||
optional<T> make_optional ( bool cond, T const& v )
|
optional<T> make_optional ( bool cond, T const& v )
|
||||||
{
|
{
|
||||||
return optional<T>(cond,v);
|
return optional<T>(cond,v);
|
||||||
@ -918,63 +878,79 @@ inline
|
|||||||
bool operator >= ( none_t x, optional<T> const& y )
|
bool operator >= ( none_t x, optional<T> const& y )
|
||||||
{ return !( x < y ) ; }
|
{ return !( x < y ) ; }
|
||||||
|
|
||||||
|
//
|
||||||
|
// The following swap implementation follows the GCC workaround as found in
|
||||||
|
// "boost/detail/compressed_pair.hpp"
|
||||||
|
//
|
||||||
namespace optional_detail {
|
namespace optional_detail {
|
||||||
|
|
||||||
template<bool use_default_constructor> struct swap_selector;
|
// GCC < 3.2 gets the using declaration at namespace scope (FLC, DWA)
|
||||||
|
#if BOOST_WORKAROUND(__GNUC__, < 3) \
|
||||||
|
|| BOOST_WORKAROUND(__GNUC__, == 3) && __GNUC_MINOR__ <= 2
|
||||||
|
using std::swap;
|
||||||
|
#define BOOST_OPTIONAL_STD_SWAP_INTRODUCED_AT_NS_SCOPE
|
||||||
|
#endif
|
||||||
|
|
||||||
template<>
|
template<bool use_default_constructor> struct swap_selector;
|
||||||
struct swap_selector<true>
|
|
||||||
{
|
template<>
|
||||||
|
struct swap_selector<true>
|
||||||
|
{
|
||||||
template<class T>
|
template<class T>
|
||||||
static void optional_swap ( optional<T>& x, optional<T>& y )
|
static void optional_swap ( optional<T>& x, optional<T>& y )
|
||||||
{
|
{
|
||||||
const bool hasX = !!x;
|
bool hasX = x;
|
||||||
const bool hasY = !!y;
|
bool hasY = y;
|
||||||
|
|
||||||
if ( !hasX && !hasY )
|
if ( !hasX && !hasY )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if( !hasX )
|
if( !hasX )
|
||||||
x = boost::in_place();
|
x = boost::in_place();
|
||||||
else if ( !hasY )
|
else if ( !hasY )
|
||||||
y = boost::in_place();
|
y = boost::in_place();
|
||||||
|
|
||||||
// Boost.Utility.Swap will take care of ADL and workarounds for broken compilers
|
// GCC > 3.2 and all other compilers have the using declaration at function scope (FLC)
|
||||||
boost::swap(x.get(),y.get());
|
#ifndef BOOST_OPTIONAL_STD_SWAP_INTRODUCED_AT_NS_SCOPE
|
||||||
|
// allow for Koenig lookup
|
||||||
|
using std::swap ;
|
||||||
|
#endif
|
||||||
|
swap(*x,*y);
|
||||||
|
|
||||||
if( !hasX )
|
if( !hasX )
|
||||||
y = boost::none ;
|
y = boost::none ;
|
||||||
else if( !hasY )
|
else if( !hasY )
|
||||||
x = boost::none ;
|
x = boost::none ;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
struct swap_selector<false>
|
struct swap_selector<false>
|
||||||
{
|
{
|
||||||
template<class T>
|
template<class T>
|
||||||
static void optional_swap ( optional<T>& x, optional<T>& y )
|
static void optional_swap ( optional<T>& x, optional<T>& y )
|
||||||
{
|
{
|
||||||
const bool hasX = !!x;
|
if ( !x && !!y )
|
||||||
const bool hasY = !!y;
|
{
|
||||||
|
x = *y;
|
||||||
if ( !hasX && hasY )
|
y = boost::none ;
|
||||||
{
|
}
|
||||||
x = y.get();
|
else if ( !!x && !y )
|
||||||
y = boost::none ;
|
{
|
||||||
}
|
y = *x ;
|
||||||
else if ( hasX && !hasY )
|
x = boost::none ;
|
||||||
{
|
}
|
||||||
y = x.get();
|
else if ( !!x && !!y )
|
||||||
x = boost::none ;
|
{
|
||||||
}
|
// GCC > 3.2 and all other compilers have the using declaration at function scope (FLC)
|
||||||
else if ( hasX && hasY )
|
#ifndef BOOST_OPTIONAL_STD_SWAP_INTRODUCED_AT_NS_SCOPE
|
||||||
{
|
// allow for Koenig lookup
|
||||||
// Boost.Utility.Swap will take care of ADL and workarounds for broken compilers
|
using std::swap ;
|
||||||
boost::swap(x.get(),y.get());
|
#endif
|
||||||
}
|
swap(*x,*y);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace optional_detail
|
} // namespace optional_detail
|
||||||
|
|
||||||
@ -983,9 +959,10 @@ struct optional_swap_should_use_default_constructor : has_nothrow_default_constr
|
|||||||
|
|
||||||
template<class T> inline void swap ( optional<T>& x, optional<T>& y )
|
template<class T> inline void swap ( optional<T>& x, optional<T>& y )
|
||||||
{
|
{
|
||||||
optional_detail::swap_selector<optional_swap_should_use_default_constructor<T>::value>::optional_swap(x, y);
|
optional_detail::swap_selector<optional_swap_should_use_default_constructor<T>::value>::optional_swap(x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace boost
|
} // namespace boost
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
// http://www.boost.org/LICENSE_1_0.txt)
|
// http://www.boost.org/LICENSE_1_0.txt)
|
||||||
//
|
//
|
||||||
// See http://www.boost.org/libs/optional for documentation.
|
// See http://www.boost.org/lib/optional for documentation.
|
||||||
//
|
//
|
||||||
// You are welcome to contact the author at:
|
// You are welcome to contact the author at:
|
||||||
// fernando_cacciola@hotmail.com
|
// fernando_cacciola@hotmail.com
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
// http://www.boost.org/LICENSE_1_0.txt)
|
// http://www.boost.org/LICENSE_1_0.txt)
|
||||||
//
|
//
|
||||||
// See http://www.boost.org/libs/optional for documentation.
|
// See http://www.boost.org/lib/optional for documentation.
|
||||||
//
|
//
|
||||||
// You are welcome to contact the author at:
|
// You are welcome to contact the author at:
|
||||||
// fernando_cacciola@hotmail.com
|
// fernando_cacciola@hotmail.com
|
||||||
@ -13,20 +13,19 @@
|
|||||||
#define BOOST_OPTIONAL_OPTIONAL_IO_FLC_19NOV2002_HPP
|
#define BOOST_OPTIONAL_OPTIONAL_IO_FLC_19NOV2002_HPP
|
||||||
|
|
||||||
#if defined __GNUC__
|
#if defined __GNUC__
|
||||||
# if (__GNUC__ == 2 && __GNUC_MINOR__ <= 97)
|
# if (__GNUC__ == 2 && __GNUC_MINOR__ <= 97)
|
||||||
# define BOOST_OPTIONAL_NO_TEMPLATED_STREAMS
|
# define BOOST_OPTIONAL_NO_TEMPLATED_STREAMS
|
||||||
# endif
|
# endif
|
||||||
#endif // __GNUC__
|
#endif // __GNUC__
|
||||||
|
|
||||||
#if defined BOOST_OPTIONAL_NO_TEMPLATED_STREAMS
|
#if defined BOOST_OPTIONAL_NO_TEMPLATED_STREAMS
|
||||||
# include <iostream>
|
# include <iostream>
|
||||||
#else
|
#else
|
||||||
# include <istream>
|
# include <istream>
|
||||||
# include <ostream>
|
# include <ostream>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#include <boost/none.hpp>
|
|
||||||
#include <boost/assert.hpp>
|
|
||||||
#include "boost/optional/optional.hpp"
|
#include "boost/optional/optional.hpp"
|
||||||
#include "boost/utility/value_init.hpp"
|
#include "boost/utility/value_init.hpp"
|
||||||
|
|
||||||
@ -63,30 +62,17 @@ std::basic_istream<CharType, CharTrait>&
|
|||||||
operator>>(std::basic_istream<CharType, CharTrait>& in, optional<T>& v)
|
operator>>(std::basic_istream<CharType, CharTrait>& in, optional<T>& v)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
if (in.good())
|
if ( in.good() )
|
||||||
{
|
{
|
||||||
int d = in.get();
|
int d = in.get();
|
||||||
if (d == ' ')
|
if ( d == ' ' )
|
||||||
{
|
{
|
||||||
T x;
|
T x ;
|
||||||
in >> x;
|
in >> x;
|
||||||
v = x;
|
v = x ;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
v = optional<T>() ;
|
||||||
if (d == '-')
|
|
||||||
{
|
|
||||||
d = in.get();
|
|
||||||
|
|
||||||
if (d == '-')
|
|
||||||
{
|
|
||||||
v = none;
|
|
||||||
return in;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
in.setstate( std::ios::failbit );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return in;
|
return in;
|
||||||
|
@ -158,27 +158,27 @@ void test_basics( T const* )
|
|||||||
ob.reset();
|
ob.reset();
|
||||||
check_is_pending_dtor( ARG(T) ) ;
|
check_is_pending_dtor( ARG(T) ) ;
|
||||||
check_uninitialized(ob);
|
check_uninitialized(ob);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
void test_conditional_ctor_and_get_valur_or ( T const* )
|
void test_conditional_ctor_and_get_valur_or ( T const* )
|
||||||
{
|
{
|
||||||
TRACE( std::endl << BOOST_CURRENT_FUNCTION );
|
TRACE( std::endl << BOOST_CURRENT_FUNCTION );
|
||||||
|
|
||||||
T a(321);
|
T a(321);
|
||||||
|
|
||||||
T z(123);
|
T z(123);
|
||||||
|
|
||||||
optional<T> const cdef0(false,a);
|
optional<T> const cdef0(false,a);
|
||||||
|
|
||||||
optional<T> def0(false,a);
|
optional<T> def0(false,a);
|
||||||
optional<T> def1 = boost::make_optional(false,a); // T is not within boost so ADL won't find make_optional unqualified
|
optional<T> def1 = boost::make_optional(false,a); // T is not within boost so ADL won't find make_optional unqualified
|
||||||
check_uninitialized(def0);
|
check_uninitialized(def0);
|
||||||
check_uninitialized(def1);
|
check_uninitialized(def1);
|
||||||
|
|
||||||
optional<T> const co0(true,a);
|
optional<T> const co0(true,a);
|
||||||
|
|
||||||
optional<T> o0(true,a);
|
optional<T> o0(true,a);
|
||||||
optional<T> o1 = boost::make_optional(true,a); // T is not within boost so ADL won't find make_optional unqualified
|
optional<T> o1 = boost::make_optional(true,a); // T is not within boost so ADL won't find make_optional unqualified
|
||||||
|
|
||||||
@ -186,65 +186,65 @@ void test_conditional_ctor_and_get_valur_or ( T const* )
|
|||||||
check_initialized(o1);
|
check_initialized(o1);
|
||||||
check_value(o0,a,z);
|
check_value(o0,a,z);
|
||||||
check_value(o1,a,z);
|
check_value(o1,a,z);
|
||||||
|
|
||||||
T b = def0.get_value_or(z);
|
T b = def0.get_value_or(z);
|
||||||
BOOST_CHECK( b == z ) ;
|
BOOST_CHECK( b == z ) ;
|
||||||
|
|
||||||
b = get_optional_value_or(def0,z);
|
b = get_optional_value_or(def0,z);
|
||||||
BOOST_CHECK( b == z ) ;
|
BOOST_CHECK( b == z ) ;
|
||||||
|
|
||||||
b = o0.get_value_or(z);
|
b = o0.get_value_or(z);
|
||||||
BOOST_CHECK( b == a ) ;
|
BOOST_CHECK( b == a ) ;
|
||||||
|
|
||||||
b = get_optional_value_or(o0,z);
|
b = get_optional_value_or(o0,z);
|
||||||
BOOST_CHECK( b == a ) ;
|
BOOST_CHECK( b == a ) ;
|
||||||
|
|
||||||
|
|
||||||
T const& crz = z ;
|
T const& crz = z ;
|
||||||
T& rz = z ;
|
T& rz = z ;
|
||||||
|
|
||||||
T const& crzz = def0.get_value_or(crz);
|
T const& crzz = def0.get_value_or(crz);
|
||||||
BOOST_CHECK( crzz == crz ) ;
|
BOOST_CHECK( crzz == crz ) ;
|
||||||
|
|
||||||
T& rzz = def0.get_value_or(rz);
|
T& rzz = def0.get_value_or(rz);
|
||||||
BOOST_CHECK( rzz == rz ) ;
|
BOOST_CHECK( rzz == rz ) ;
|
||||||
|
|
||||||
T const& crzzz = get_optional_value_or(cdef0,crz);
|
T const& crzzz = get_optional_value_or(cdef0,crz);
|
||||||
BOOST_CHECK( crzzz == crz ) ;
|
BOOST_CHECK( crzzz == crz ) ;
|
||||||
|
|
||||||
T& rzzz = get_optional_value_or(def0,rz);
|
T& rzzz = get_optional_value_or(def0,rz);
|
||||||
BOOST_CHECK( rzzz == rz ) ;
|
BOOST_CHECK( rzzz == rz ) ;
|
||||||
|
|
||||||
T const& crb = o0.get_value_or(crz);
|
T const& crb = o0.get_value_or(crz);
|
||||||
BOOST_CHECK( crb == a ) ;
|
BOOST_CHECK( crb == a ) ;
|
||||||
|
|
||||||
T& rb = o0.get_value_or(rz);
|
T& rb = o0.get_value_or(rz);
|
||||||
BOOST_CHECK( rb == b ) ;
|
BOOST_CHECK( rb == b ) ;
|
||||||
|
|
||||||
T const& crbb = get_optional_value_or(co0,crz);
|
T const& crbb = get_optional_value_or(co0,crz);
|
||||||
BOOST_CHECK( crbb == b ) ;
|
BOOST_CHECK( crbb == b ) ;
|
||||||
|
|
||||||
T const& crbbb = get_optional_value_or(o0,crz);
|
T const& crbbb = get_optional_value_or(o0,crz);
|
||||||
BOOST_CHECK( crbbb == b ) ;
|
BOOST_CHECK( crbbb == b ) ;
|
||||||
|
|
||||||
T& rbb = get_optional_value_or(o0,rz);
|
T& rbb = get_optional_value_or(o0,rz);
|
||||||
BOOST_CHECK( rbb == b ) ;
|
BOOST_CHECK( rbb == b ) ;
|
||||||
|
|
||||||
T& ra = a ;
|
T& ra = a ;
|
||||||
|
|
||||||
optional<T&> defref(false,ra);
|
optional<T&> defref(false,ra);
|
||||||
BOOST_CHECK(!defref);
|
BOOST_CHECK(!defref);
|
||||||
|
|
||||||
optional<T&> ref(true,ra);
|
optional<T&> ref(true,ra);
|
||||||
BOOST_CHECK(!!ref);
|
BOOST_CHECK(!!ref);
|
||||||
|
|
||||||
a = T(432);
|
a = T(432);
|
||||||
|
|
||||||
BOOST_CHECK( *ref == a ) ;
|
BOOST_CHECK( *ref == a ) ;
|
||||||
|
|
||||||
T& r1 = defref.get_value_or(z);
|
T& r1 = defref.get_value_or(z);
|
||||||
BOOST_CHECK( r1 == z ) ;
|
BOOST_CHECK( r1 == z ) ;
|
||||||
|
|
||||||
T& r2 = ref.get_value_or(z);
|
T& r2 = ref.get_value_or(z);
|
||||||
BOOST_CHECK( r2 == a ) ;
|
BOOST_CHECK( r2 == a ) ;
|
||||||
}
|
}
|
||||||
@ -718,7 +718,7 @@ void test_relops( T const* )
|
|||||||
optional<T> opt0(v0);
|
optional<T> opt0(v0);
|
||||||
optional<T> opt1(v1);
|
optional<T> opt1(v1);
|
||||||
optional<T> opt2(v2);
|
optional<T> opt2(v2);
|
||||||
|
|
||||||
// Check identity
|
// Check identity
|
||||||
BOOST_CHECK ( def0 == def0 ) ;
|
BOOST_CHECK ( def0 == def0 ) ;
|
||||||
BOOST_CHECK ( opt0 == opt0 ) ;
|
BOOST_CHECK ( opt0 == opt0 ) ;
|
||||||
@ -756,7 +756,7 @@ void test_relops( T const* )
|
|||||||
BOOST_CHECK ( opt1 > opt0 ) ;
|
BOOST_CHECK ( opt1 > opt0 ) ;
|
||||||
BOOST_CHECK ( opt1 <= opt2 ) ;
|
BOOST_CHECK ( opt1 <= opt2 ) ;
|
||||||
BOOST_CHECK ( opt1 >= opt0 ) ;
|
BOOST_CHECK ( opt1 >= opt0 ) ;
|
||||||
|
|
||||||
// Compare against a value directly
|
// Compare against a value directly
|
||||||
BOOST_CHECK ( opt0 == v0 ) ;
|
BOOST_CHECK ( opt0 == v0 ) ;
|
||||||
BOOST_CHECK ( opt0 != v1 ) ;
|
BOOST_CHECK ( opt0 != v1 ) ;
|
||||||
@ -799,7 +799,7 @@ void test_none( T const* )
|
|||||||
BOOST_CHECK ( def0 == none ) ;
|
BOOST_CHECK ( def0 == none ) ;
|
||||||
BOOST_CHECK ( non_def != none ) ;
|
BOOST_CHECK ( non_def != none ) ;
|
||||||
BOOST_CHECK ( !def1 ) ;
|
BOOST_CHECK ( !def1 ) ;
|
||||||
BOOST_CHECK ( !(non_def < none) ) ;
|
BOOST_CHECK ( !(non_def < none) ) ;
|
||||||
BOOST_CHECK ( non_def > none ) ;
|
BOOST_CHECK ( non_def > none ) ;
|
||||||
BOOST_CHECK ( !(non_def <= none) ) ;
|
BOOST_CHECK ( !(non_def <= none) ) ;
|
||||||
BOOST_CHECK ( non_def >= none ) ;
|
BOOST_CHECK ( non_def >= none ) ;
|
||||||
@ -819,11 +819,11 @@ void test_arrow( T const* )
|
|||||||
|
|
||||||
optional<T> oa(a) ;
|
optional<T> oa(a) ;
|
||||||
optional<T> const coa(a) ;
|
optional<T> const coa(a) ;
|
||||||
|
|
||||||
BOOST_CHECK ( coa->V() == 1234 ) ;
|
BOOST_CHECK ( coa->V() == 1234 ) ;
|
||||||
|
|
||||||
oa->V() = 4321 ;
|
oa->V() = 4321 ;
|
||||||
|
|
||||||
BOOST_CHECK ( a.V() = 1234 ) ;
|
BOOST_CHECK ( a.V() = 1234 ) ;
|
||||||
BOOST_CHECK ( (*oa).V() = 4321 ) ;
|
BOOST_CHECK ( (*oa).V() = 4321 ) ;
|
||||||
}
|
}
|
||||||
@ -1086,7 +1086,7 @@ namespace optional_swap_test
|
|||||||
x = boost::in_place('\0');
|
x = boost::in_place('\0');
|
||||||
else if ( !hasY )
|
else if ( !hasY )
|
||||||
y = boost::in_place('\0');
|
y = boost::in_place('\0');
|
||||||
|
|
||||||
optional_swap_test::swap(*x,*y);
|
optional_swap_test::swap(*x,*y);
|
||||||
|
|
||||||
if( !hasX )
|
if( !hasX )
|
||||||
@ -1118,7 +1118,7 @@ template <class T> struct optional_swap_should_use_default_constructor<
|
|||||||
//
|
//
|
||||||
// Specialization of boost::swap:
|
// Specialization of boost::swap:
|
||||||
//
|
//
|
||||||
template <>
|
template <>
|
||||||
void swap(optional<optional_swap_test::class_whose_explicit_ctor_should_be_used> & x, optional<optional_swap_test::class_whose_explicit_ctor_should_be_used> & y)
|
void swap(optional<optional_swap_test::class_whose_explicit_ctor_should_be_used> & x, optional<optional_swap_test::class_whose_explicit_ctor_should_be_used> & y)
|
||||||
{
|
{
|
||||||
optional_swap_test::swap(x, y);
|
optional_swap_test::swap(x, y);
|
||||||
@ -1133,25 +1133,25 @@ namespace std {
|
|||||||
// Specializations of std::swap:
|
// Specializations of std::swap:
|
||||||
//
|
//
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
void swap(optional_swap_test::class_whose_default_ctor_should_be_used & x, optional_swap_test::class_whose_default_ctor_should_be_used & y)
|
void swap(optional_swap_test::class_whose_default_ctor_should_be_used & x, optional_swap_test::class_whose_default_ctor_should_be_used & y)
|
||||||
{
|
{
|
||||||
optional_swap_test::swap(x, y);
|
optional_swap_test::swap(x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
void swap(optional_swap_test::class_whose_default_ctor_should_not_be_used & x, optional_swap_test::class_whose_default_ctor_should_not_be_used & y)
|
void swap(optional_swap_test::class_whose_default_ctor_should_not_be_used & x, optional_swap_test::class_whose_default_ctor_should_not_be_used & y)
|
||||||
{
|
{
|
||||||
optional_swap_test::swap(x, y);
|
optional_swap_test::swap(x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
void swap(optional_swap_test::class_without_default_ctor & x, optional_swap_test::class_without_default_ctor & y)
|
void swap(optional_swap_test::class_without_default_ctor & x, optional_swap_test::class_without_default_ctor & y)
|
||||||
{
|
{
|
||||||
optional_swap_test::swap(x, y);
|
optional_swap_test::swap(x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
void swap(optional_swap_test::class_whose_explicit_ctor_should_be_used & x, optional_swap_test::class_whose_explicit_ctor_should_be_used & y)
|
void swap(optional_swap_test::class_whose_explicit_ctor_should_be_used & x, optional_swap_test::class_whose_explicit_ctor_should_be_used & y)
|
||||||
{
|
{
|
||||||
optional_swap_test::swap(x, y);
|
optional_swap_test::swap(x, y);
|
||||||
@ -1204,7 +1204,7 @@ bool test_swap_function( T const* )
|
|||||||
|
|
||||||
//
|
//
|
||||||
// Tests whether the optional<T>::swap member function works properly.
|
// Tests whether the optional<T>::swap member function works properly.
|
||||||
// Assumes that T has one data member, of type char.
|
// Assumes that T has one data member, of type char.
|
||||||
// Returns true iff the test is passed.
|
// Returns true iff the test is passed.
|
||||||
//
|
//
|
||||||
template <class T>
|
template <class T>
|
||||||
@ -1263,33 +1263,6 @@ void test_swap_tweaking()
|
|||||||
BOOST_CHECK( test_swap_member_function( ARG(optional_swap_test::template_whose_default_ctor_should_be_used<char>) ) );
|
BOOST_CHECK( test_swap_member_function( ARG(optional_swap_test::template_whose_default_ctor_should_be_used<char>) ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test for support for classes with overridden operator&
|
|
||||||
class CustomAddressOfClass
|
|
||||||
{
|
|
||||||
int n;
|
|
||||||
|
|
||||||
public:
|
|
||||||
CustomAddressOfClass() : n(0) {}
|
|
||||||
CustomAddressOfClass(CustomAddressOfClass const& that) : n(that.n) {}
|
|
||||||
explicit CustomAddressOfClass(int m) : n(m) {}
|
|
||||||
int* operator& () { return &n; }
|
|
||||||
bool operator== (CustomAddressOfClass const& that) const { return n == that.n; }
|
|
||||||
};
|
|
||||||
|
|
||||||
void test_custom_addressof_operator()
|
|
||||||
{
|
|
||||||
boost::optional< CustomAddressOfClass > o1(CustomAddressOfClass(10));
|
|
||||||
BOOST_CHECK(!!o1);
|
|
||||||
BOOST_CHECK(o1.get() == CustomAddressOfClass(10));
|
|
||||||
|
|
||||||
o1 = CustomAddressOfClass(20);
|
|
||||||
BOOST_CHECK(!!o1);
|
|
||||||
BOOST_CHECK(o1.get() == CustomAddressOfClass(20));
|
|
||||||
|
|
||||||
o1 = boost::none;
|
|
||||||
BOOST_CHECK(!o1);
|
|
||||||
}
|
|
||||||
|
|
||||||
int test_main( int, char* [] )
|
int test_main( int, char* [] )
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@ -1300,7 +1273,6 @@ int test_main( int, char* [] )
|
|||||||
test_conversions1();
|
test_conversions1();
|
||||||
test_conversions2();
|
test_conversions2();
|
||||||
test_swap_tweaking();
|
test_swap_tweaking();
|
||||||
test_custom_addressof_operator();
|
|
||||||
}
|
}
|
||||||
catch ( ... )
|
catch ( ... )
|
||||||
{
|
{
|
||||||
|
@ -55,14 +55,10 @@ void test2( Opt o, Opt buff )
|
|||||||
{
|
{
|
||||||
stringstream s ;
|
stringstream s ;
|
||||||
|
|
||||||
const int markv = 123 ;
|
s << o ;
|
||||||
int mark = 0 ;
|
s >> buff ;
|
||||||
|
|
||||||
s << o << " " << markv ;
|
|
||||||
s >> buff >> mark ;
|
|
||||||
|
|
||||||
BOOST_ASSERT( buff == o ) ;
|
BOOST_ASSERT( buff == o ) ;
|
||||||
BOOST_ASSERT( mark == markv ) ;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -81,6 +77,7 @@ int test_main( int, char* [] )
|
|||||||
{
|
{
|
||||||
test(1,2);
|
test(1,2);
|
||||||
test(string("hello"),string("buffer"));
|
test(string("hello"),string("buffer"));
|
||||||
|
test(string(""),string("buffer"));
|
||||||
}
|
}
|
||||||
catch ( ... )
|
catch ( ... )
|
||||||
{
|
{
|
||||||
|
@ -342,14 +342,14 @@ void test_binding()
|
|||||||
int i = 0 ;
|
int i = 0 ;
|
||||||
optional<int&> ori1 = i ;
|
optional<int&> ori1 = i ;
|
||||||
BOOST_CHECK( &(*ori1) == &i ) ;
|
BOOST_CHECK( &(*ori1) == &i ) ;
|
||||||
|
|
||||||
optional<int&> ori2(i) ;
|
optional<int&> ori2(i) ;
|
||||||
BOOST_CHECK( &(*ori2) == &i ) ;
|
BOOST_CHECK( &(*ori2) == &i ) ;
|
||||||
|
|
||||||
int const ci = 0 ;
|
int const ci = 0 ;
|
||||||
optional<int const&> orci1 = ci ;
|
optional<int const&> orci1 = ci ;
|
||||||
BOOST_CHECK( &(*orci1) == &ci ) ;
|
BOOST_CHECK( &(*orci1) == &ci ) ;
|
||||||
|
|
||||||
optional<int const&> orci2(ci) ;
|
optional<int const&> orci2(ci) ;
|
||||||
BOOST_CHECK( &(*orci2) == &ci ) ;
|
BOOST_CHECK( &(*orci2) == &ci ) ;
|
||||||
}
|
}
|
||||||
@ -360,7 +360,7 @@ int test_main( int, char* [] )
|
|||||||
{
|
{
|
||||||
test_with_class_type();
|
test_with_class_type();
|
||||||
test_with_builtin_types();
|
test_with_builtin_types();
|
||||||
test_binding();
|
test_binding();
|
||||||
}
|
}
|
||||||
catch ( ... )
|
catch ( ... )
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user