Compare commits
14 Commits
svn-branch
...
svn-branch
Author | SHA1 | Date | |
---|---|---|---|
da8f2d028e | |||
16f0a0aaaf | |||
a63dbe0f14 | |||
066dd6f345 | |||
4e628ed4a6 | |||
8682f2bbaa | |||
fea89e84f3 | |||
2772bfc08d | |||
361943e033 | |||
20c9fc8ebe | |||
fd38be1636 | |||
9f655c6932 | |||
e7d7b014d2 | |||
2af3ec341b |
@ -12,6 +12,8 @@
|
|||||||
|
|
||||||
import quickbook ;
|
import quickbook ;
|
||||||
|
|
||||||
|
path-constant images : html ;
|
||||||
|
|
||||||
xml optional
|
xml optional
|
||||||
:
|
:
|
||||||
optional.qbk
|
optional.qbk
|
||||||
@ -26,5 +28,8 @@ boostbook standalone
|
|||||||
<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
|
||||||
;
|
;
|
||||||
|
|
||||||
|
|
||||||
|
@ -3,8 +3,8 @@
|
|||||||
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
<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.73.2">
|
<meta name="generator" content="DocBook XSL Stylesheets V1.75.2">
|
||||||
<link rel="start" href="../index.html" title="Chapter<65>1.<2E>Boost.Optional">
|
<link rel="home" href="../index.html" title="Chapter<65>1.<2E>Boost.Optional">
|
||||||
<link rel="up" href="../index.html" title="Chapter<65>1.<2E>Boost.Optional">
|
<link rel="up" href="../index.html" title="Chapter<65>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">
|
||||||
@ -22,7 +22,7 @@
|
|||||||
<div class="spirit-nav">
|
<div class="spirit-nav">
|
||||||
<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>
|
<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" lang="en">
|
<div class="section" title="A note about optional<bool>">
|
||||||
<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 class="link" href="a_note_about_optional_bool_.html" title="A note about optional<bool>">A note about
|
||||||
optional<bool></a>
|
optional<bool></a>
|
||||||
|
@ -3,8 +3,8 @@
|
|||||||
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
<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.73.2">
|
<meta name="generator" content="DocBook XSL Stylesheets V1.75.2">
|
||||||
<link rel="start" href="../index.html" title="Chapter<65>1.<2E>Boost.Optional">
|
<link rel="home" href="../index.html" title="Chapter<65>1.<2E>Boost.Optional">
|
||||||
<link rel="up" href="../index.html" title="Chapter<65>1.<2E>Boost.Optional">
|
<link rel="up" href="../index.html" title="Chapter<65>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>
|
||||||
@ -21,89 +21,89 @@
|
|||||||
<div class="spirit-nav">
|
<div class="spirit-nav">
|
||||||
<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>
|
<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" lang="en">
|
<div class="section" title="Acknowledgments">
|
||||||
<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 class="link" 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="id2865262"></a>
|
<a name="id583998"></a>
|
||||||
<a class="link" href="acknowledgments.html#boost_optional.acknowledgments.pre_formal_review">Pre-formal
|
<a class="link" href="acknowledgments.html#boost_optional.acknowledgments.pre_formal_review">Pre-formal
|
||||||
review</a>
|
review</a>
|
||||||
</h4>
|
</h4>
|
||||||
<div class="itemizedlist"><ul type="disc">
|
<div class="itemizedlist"><ul class="itemizedlist" type="disc">
|
||||||
<li>
|
<li class="listitem">
|
||||||
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>
|
<li class="listitem">
|
||||||
Douglas Gregor developed 'type_with_alignment', and later Eric Friedman coded
|
Douglas Gregor developed 'type_with_alignment', and later Eric Friedman 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>
|
<li class="listitem">
|
||||||
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>
|
<li class="listitem">
|
||||||
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>
|
<li class="listitem">
|
||||||
Vesa Karvonen and Douglas Gregor made quite useful comparisons between optional,
|
Vesa Karvonen and Douglas Gregor made quite useful comparisons between optional,
|
||||||
variant and any; and made other relevant comments.
|
variant and any; and made other relevant comments.
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li class="listitem">
|
||||||
Douglas Gregor and Peter Dimov commented on comparisons and evaluation in
|
Douglas Gregor and Peter Dimov commented on comparisons and evaluation in
|
||||||
boolean contexts.
|
boolean contexts.
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li class="listitem">
|
||||||
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>
|
<li class="listitem">
|
||||||
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="id2865331"></a>
|
<a name="id584068"></a>
|
||||||
<a class="link" href="acknowledgments.html#boost_optional.acknowledgments.post_formal_review">Post-formal
|
<a class="link" href="acknowledgments.html#boost_optional.acknowledgments.post_formal_review">Post-formal
|
||||||
review</a>
|
review</a>
|
||||||
</h4>
|
</h4>
|
||||||
<div class="itemizedlist"><ul type="disc">
|
<div class="itemizedlist"><ul class="itemizedlist" type="disc">
|
||||||
<li>
|
<li class="listitem">
|
||||||
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 and
|
fueled the discussion about the analogy optional<>/smart pointer and
|
||||||
about relational operators.
|
about relational operators.
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li class="listitem">
|
||||||
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); concluding
|
focused on the relational semantics of optional (originally undefined); concluding
|
||||||
with the fact that the pointer-like interface doesn't make it a pointer so
|
with the fact that the pointer-like interface doesn't make it a pointer so
|
||||||
it shall have deep relational operators.
|
it shall have deep relational operators.
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li class="listitem">
|
||||||
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>
|
<li class="listitem">
|
||||||
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>
|
<li class="listitem">
|
||||||
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>
|
<li class="listitem">
|
||||||
Other comments were posted by Vincent Finn, Anthony Williams, Ed Brey, Rob
|
Other comments were posted by Vincent Finn, Anthony Williams, Ed Brey, Rob
|
||||||
Stewart, and others.
|
Stewart, and others.
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li class="listitem">
|
||||||
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>
|
<li class="listitem">
|
||||||
Mat Marcus shown the virtues of a value-oriented interface, influencing the
|
Mat Marcus shown the virtues of a value-oriented interface, influencing the
|
||||||
current design, and contributed the idea of "none".
|
current design, and contributed the idea of "none".
|
||||||
</li>
|
</li>
|
||||||
|
@ -3,8 +3,8 @@
|
|||||||
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
<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.73.2">
|
<meta name="generator" content="DocBook XSL Stylesheets V1.75.2">
|
||||||
<link rel="start" href="../index.html" title="Chapter<65>1.<2E>Boost.Optional">
|
<link rel="home" href="../index.html" title="Chapter<65>1.<2E>Boost.Optional">
|
||||||
<link rel="up" href="../index.html" title="Chapter<65>1.<2E>Boost.Optional">
|
<link rel="up" href="../index.html" title="Chapter<65>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">
|
||||||
@ -22,7 +22,7 @@
|
|||||||
<div class="spirit-nav">
|
<div class="spirit-nav">
|
||||||
<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>
|
<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" lang="en">
|
<div class="section" title="Dependencies and Portability">
|
||||||
<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 class="link" href="dependencies_and_portability.html" title="Dependencies and Portability">Dependencies
|
||||||
and Portability</a>
|
and Portability</a>
|
||||||
|
@ -3,8 +3,8 @@
|
|||||||
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
||||||
<title>Detailed Semantics</title>
|
<title>Detailed Semantics</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.73.2">
|
<meta name="generator" content="DocBook XSL Stylesheets V1.75.2">
|
||||||
<link rel="start" href="../index.html" title="Chapter<65>1.<2E>Boost.Optional">
|
<link rel="home" href="../index.html" title="Chapter<65>1.<2E>Boost.Optional">
|
||||||
<link rel="up" href="../index.html" title="Chapter<65>1.<2E>Boost.Optional">
|
<link rel="up" href="../index.html" title="Chapter<65>1.<2E>Boost.Optional">
|
||||||
<link rel="prev" href="synopsis.html" title="Synopsis">
|
<link rel="prev" href="synopsis.html" title="Synopsis">
|
||||||
<link rel="next" href="examples.html" title="Examples">
|
<link rel="next" href="examples.html" title="Examples">
|
||||||
@ -22,7 +22,7 @@
|
|||||||
<div class="spirit-nav">
|
<div class="spirit-nav">
|
||||||
<a accesskey="p" href="synopsis.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="examples.html"><img src="../../../../../doc/html/images/next.png" alt="Next"></a>
|
<a accesskey="p" href="synopsis.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="examples.html"><img src="../../../../../doc/html/images/next.png" alt="Next"></a>
|
||||||
</div>
|
</div>
|
||||||
<div class="section" lang="en">
|
<div class="section" title="Detailed Semantics">
|
||||||
<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.detailed_semantics"></a><a class="link" href="detailed_semantics.html" title="Detailed Semantics">Detailed Semantics</a>
|
<a name="boost_optional.detailed_semantics"></a><a class="link" href="detailed_semantics.html" title="Detailed Semantics">Detailed Semantics</a>
|
||||||
</h2></div></div></div>
|
</h2></div></div></div>
|
||||||
@ -31,24 +31,24 @@
|
|||||||
type, in the sequel, those entries whose semantic depends on <code class="computeroutput"><span class="identifier">T</span></code> being of reference type or not will be
|
type, in the sequel, those entries whose semantic depends on <code class="computeroutput"><span class="identifier">T</span></code> being of reference type or not will be
|
||||||
distinguished using the following convention:
|
distinguished using the following convention:
|
||||||
</p>
|
</p>
|
||||||
<div class="itemizedlist"><ul type="disc">
|
<div class="itemizedlist"><ul class="itemizedlist" type="disc">
|
||||||
<li>
|
<li class="listitem">
|
||||||
If the entry reads: <code class="computeroutput"><span class="identifier">optional</span><span class="special"><</span><span class="identifier">T</span></code><span class="emphasis"><em>(not
|
If the entry reads: <code class="computeroutput"><span class="identifier">optional</span><span class="special"><</span><span class="identifier">T</span></code><span class="emphasis"><em>(not
|
||||||
a ref)</em></span><code class="computeroutput"><span class="special">></span></code>, the description
|
a ref)</em></span><code class="computeroutput"><span class="special">></span></code>, the description
|
||||||
corresponds only to the case where <code class="computeroutput"><span class="identifier">T</span></code>
|
corresponds only to the case where <code class="computeroutput"><span class="identifier">T</span></code>
|
||||||
is not of reference type.
|
is not of reference type.
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li class="listitem">
|
||||||
If the entry reads: <code class="computeroutput"><span class="identifier">optional</span><span class="special"><</span><span class="identifier">T</span><span class="special">&></span></code>,
|
If the entry reads: <code class="computeroutput"><span class="identifier">optional</span><span class="special"><</span><span class="identifier">T</span><span class="special">&></span></code>,
|
||||||
the description corresponds only to the case where <code class="computeroutput"><span class="identifier">T</span></code>
|
the description corresponds only to the case where <code class="computeroutput"><span class="identifier">T</span></code>
|
||||||
is of reference type.
|
is of reference type.
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li class="listitem">
|
||||||
If the entry reads: <code class="computeroutput"><span class="identifier">optional</span><span class="special"><</span><span class="identifier">T</span><span class="special">></span></code>,
|
If the entry reads: <code class="computeroutput"><span class="identifier">optional</span><span class="special"><</span><span class="identifier">T</span><span class="special">></span></code>,
|
||||||
the description is the same for both cases.
|
the description is the same for both cases.
|
||||||
</li>
|
</li>
|
||||||
</ul></div>
|
</ul></div>
|
||||||
<div class="note"><table border="0" summary="Note">
|
<div class="note" title="Note"><table border="0" summary="Note">
|
||||||
<tr>
|
<tr>
|
||||||
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../../../doc/html/images/note.png"></td>
|
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../../../doc/html/images/note.png"></td>
|
||||||
<th align="left">Note</th>
|
<th align="left">Note</th>
|
||||||
@ -64,7 +64,7 @@
|
|||||||
<span class="inlinemediaobject"><img src="../images/space.png" alt="space"></span>
|
<span class="inlinemediaobject"><img src="../images/space.png" alt="space"></span>
|
||||||
</p>
|
</p>
|
||||||
<a name="boost_optional.detailed_semantics.optional_class_member_functions"></a><h4>
|
<a name="boost_optional.detailed_semantics.optional_class_member_functions"></a><h4>
|
||||||
<a name="id2841077"></a>
|
<a name="id560085"></a>
|
||||||
<a class="link" href="detailed_semantics.html#boost_optional.detailed_semantics.optional_class_member_functions">optional
|
<a class="link" href="detailed_semantics.html#boost_optional.detailed_semantics.optional_class_member_functions">optional
|
||||||
class member functions</a>
|
class member functions</a>
|
||||||
</h4>
|
</h4>
|
||||||
@ -82,21 +82,21 @@
|
|||||||
<p>
|
<p>
|
||||||
</p>
|
</p>
|
||||||
</blockquote></div>
|
</blockquote></div>
|
||||||
<div class="itemizedlist"><ul type="disc">
|
<div class="itemizedlist"><ul class="itemizedlist" type="disc">
|
||||||
<li>
|
<li class="listitem">
|
||||||
<span class="bold"><strong>Effect:</strong></span> Default-Constructs an <code class="computeroutput"><span class="identifier">optional</span></code>.
|
<span class="bold"><strong>Effect:</strong></span> Default-Constructs an <code class="computeroutput"><span class="identifier">optional</span></code>.
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li class="listitem">
|
||||||
<span class="bold"><strong>Postconditions:</strong></span><code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> is <span class="underline">uninitialized</span>.
|
<span class="bold"><strong>Postconditions:</strong></span><code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> is <span class="underline">uninitialized</span>.
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li class="listitem">
|
||||||
<span class="bold"><strong>Throws:</strong></span> Nothing.
|
<span class="bold"><strong>Throws:</strong></span> Nothing.
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li class="listitem">
|
||||||
Notes: T's default constructor <span class="underline">is not</span>
|
Notes: T's default constructor <span class="underline">is not</span>
|
||||||
called.
|
called.
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li class="listitem">
|
||||||
<span class="bold"><strong>Example:</strong></span><pre class="programlisting"><span class="identifier">optional</span><span class="special"><</span><span class="identifier">T</span><span class="special">></span> <span class="identifier">def</span> <span class="special">;</span>
|
<span class="bold"><strong>Example:</strong></span><pre class="programlisting"><span class="identifier">optional</span><span class="special"><</span><span class="identifier">T</span><span class="special">></span> <span class="identifier">def</span> <span class="special">;</span>
|
||||||
<span class="identifier">assert</span> <span class="special">(</span> <span class="special">!</span><span class="identifier">def</span> <span class="special">)</span> <span class="special">;</span>
|
<span class="identifier">assert</span> <span class="special">(</span> <span class="special">!</span><span class="identifier">def</span> <span class="special">)</span> <span class="special">;</span>
|
||||||
</pre>
|
</pre>
|
||||||
@ -116,23 +116,23 @@
|
|||||||
<p>
|
<p>
|
||||||
</p>
|
</p>
|
||||||
</blockquote></div>
|
</blockquote></div>
|
||||||
<div class="itemizedlist"><ul type="disc">
|
<div class="itemizedlist"><ul class="itemizedlist" type="disc">
|
||||||
<li>
|
<li class="listitem">
|
||||||
<span class="bold"><strong>Effect:</strong></span> Constructs an <code class="computeroutput"><span class="identifier">optional</span></code>
|
<span class="bold"><strong>Effect:</strong></span> Constructs an <code class="computeroutput"><span class="identifier">optional</span></code>
|
||||||
uninitialized.
|
uninitialized.
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li class="listitem">
|
||||||
<span class="bold"><strong>Postconditions:</strong></span><code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> is <span class="underline">uninitialized</span>.
|
<span class="bold"><strong>Postconditions:</strong></span><code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> is <span class="underline">uninitialized</span>.
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li class="listitem">
|
||||||
<span class="bold"><strong>Throws:</strong></span> Nothing.
|
<span class="bold"><strong>Throws:</strong></span> Nothing.
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li class="listitem">
|
||||||
<span class="bold"><strong>Notes:</strong></span><code class="computeroutput"><span class="identifier">T</span></code>'s
|
<span class="bold"><strong>Notes:</strong></span><code class="computeroutput"><span class="identifier">T</span></code>'s
|
||||||
default constructor <span class="underline">is not</span> called.
|
default constructor <span class="underline">is not</span> called.
|
||||||
The expression <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">none</span></code> denotes an instance of <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">none_t</span></code> that can be used as the parameter.
|
The expression <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">none</span></code> denotes an instance of <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">none_t</span></code> that can be used as the parameter.
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li class="listitem">
|
||||||
<span class="bold"><strong>Example:</strong></span><pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">none</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span>
|
<span class="bold"><strong>Example:</strong></span><pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">none</span><span class="special">.</span><span class="identifier">hpp</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">n</span><span class="special">(</span><span class="identifier">none</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="identifier">n</span><span class="special">(</span><span class="identifier">none</span><span class="special">)</span> <span class="special">;</span>
|
||||||
<span class="identifier">assert</span> <span class="special">(</span> <span class="special">!</span><span class="identifier">n</span> <span class="special">)</span> <span class="special">;</span>
|
<span class="identifier">assert</span> <span class="special">(</span> <span class="special">!</span><span class="identifier">n</span> <span class="special">)</span> <span class="special">;</span>
|
||||||
@ -153,31 +153,31 @@
|
|||||||
<p>
|
<p>
|
||||||
</p>
|
</p>
|
||||||
</blockquote></div>
|
</blockquote></div>
|
||||||
<div class="itemizedlist"><ul type="disc">
|
<div class="itemizedlist"><ul class="itemizedlist" type="disc">
|
||||||
<li>
|
<li class="listitem">
|
||||||
<span class="bold"><strong>Effect:</strong></span> Directly-Constructs an <code class="computeroutput"><span class="identifier">optional</span></code>.
|
<span class="bold"><strong>Effect:</strong></span> Directly-Constructs an <code class="computeroutput"><span class="identifier">optional</span></code>.
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li class="listitem">
|
||||||
<span class="bold"><strong>Postconditions:</strong></span><code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> is <span class="underline">initialized</span>
|
<span class="bold"><strong>Postconditions:</strong></span><code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> is <span class="underline">initialized</span>
|
||||||
and its value is a<span class="emphasis"><em>copy</em></span> of <code class="computeroutput"><span class="identifier">v</span></code>.
|
and its value is a<span class="emphasis"><em>copy</em></span> of <code class="computeroutput"><span class="identifier">v</span></code>.
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li class="listitem">
|
||||||
<span class="bold"><strong>Throws:</strong></span> Whatever <code class="computeroutput"><span class="identifier">T</span><span class="special">::</span><span class="identifier">T</span><span class="special">(</span>
|
<span class="bold"><strong>Throws:</strong></span> Whatever <code class="computeroutput"><span class="identifier">T</span><span class="special">::</span><span class="identifier">T</span><span class="special">(</span>
|
||||||
<span class="identifier">T</span> <span class="keyword">const</span><span class="special">&</span> <span class="special">)</span></code> throws.
|
<span class="identifier">T</span> <span class="keyword">const</span><span class="special">&</span> <span class="special">)</span></code> throws.
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li class="listitem">
|
||||||
<span class="bold"><strong>Notes: </strong></span><code class="computeroutput"><span class="identifier">T</span><span class="special">::</span><span class="identifier">T</span><span class="special">(</span>
|
<span class="bold"><strong>Notes: </strong></span><code class="computeroutput"><span class="identifier">T</span><span class="special">::</span><span class="identifier">T</span><span class="special">(</span>
|
||||||
<span class="identifier">T</span> <span class="keyword">const</span><span class="special">&</span> <span class="special">)</span></code> is
|
<span class="identifier">T</span> <span class="keyword">const</span><span class="special">&</span> <span class="special">)</span></code> is
|
||||||
called.
|
called.
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li class="listitem">
|
||||||
<span class="bold"><strong>Exception Safety:</strong></span> Exceptions can only be
|
<span class="bold"><strong>Exception Safety:</strong></span> Exceptions can only be
|
||||||
thrown during <code class="computeroutput"><span class="identifier">T</span><span class="special">::</span><span class="identifier">T</span><span class="special">(</span> <span class="identifier">T</span>
|
thrown during <code class="computeroutput"><span class="identifier">T</span><span class="special">::</span><span class="identifier">T</span><span class="special">(</span> <span class="identifier">T</span>
|
||||||
<span class="keyword">const</span><span class="special">&</span>
|
<span class="keyword">const</span><span class="special">&</span>
|
||||||
<span class="special">);</span></code> in that case, this constructor
|
<span class="special">);</span></code> in that case, this constructor
|
||||||
has no effect.
|
has no effect.
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li class="listitem">
|
||||||
<span class="bold"><strong>Example:</strong></span><pre class="programlisting"><span class="identifier">T</span> <span class="identifier">v</span><span class="special">;</span>
|
<span class="bold"><strong>Example:</strong></span><pre class="programlisting"><span class="identifier">T</span> <span class="identifier">v</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="identifier">v</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="identifier">v</span><span class="special">);</span>
|
||||||
<span class="identifier">assert</span> <span class="special">(</span> <span class="special">*</span><span class="identifier">opt</span> <span class="special">==</span> <span class="identifier">v</span> <span class="special">)</span> <span class="special">;</span>
|
<span class="identifier">assert</span> <span class="special">(</span> <span class="special">*</span><span class="identifier">opt</span> <span class="special">==</span> <span class="identifier">v</span> <span class="special">)</span> <span class="special">;</span>
|
||||||
@ -196,19 +196,19 @@
|
|||||||
<p>
|
<p>
|
||||||
</p>
|
</p>
|
||||||
</blockquote></div>
|
</blockquote></div>
|
||||||
<div class="itemizedlist"><ul type="disc">
|
<div class="itemizedlist"><ul class="itemizedlist" type="disc">
|
||||||
<li>
|
<li class="listitem">
|
||||||
<span class="bold"><strong>Effect:</strong></span> Directly-Constructs an <code class="computeroutput"><span class="identifier">optional</span></code>.
|
<span class="bold"><strong>Effect:</strong></span> Directly-Constructs an <code class="computeroutput"><span class="identifier">optional</span></code>.
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li class="listitem">
|
||||||
<span class="bold"><strong>Postconditions:</strong></span><code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> is <span class="underline">initialized</span>
|
<span class="bold"><strong>Postconditions:</strong></span><code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> is <span class="underline">initialized</span>
|
||||||
and its value is an instance of an internal type wrapping the reference
|
and its value is an instance of an internal type wrapping the reference
|
||||||
<code class="computeroutput"><span class="identifier">ref</span></code>.
|
<code class="computeroutput"><span class="identifier">ref</span></code>.
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li class="listitem">
|
||||||
<span class="bold"><strong>Throws:</strong></span> Nothing.
|
<span class="bold"><strong>Throws:</strong></span> Nothing.
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li class="listitem">
|
||||||
<span class="bold"><strong>Example:</strong></span><pre class="programlisting"><span class="identifier">T</span> <span class="identifier">v</span><span class="special">;</span>
|
<span class="bold"><strong>Example:</strong></span><pre class="programlisting"><span class="identifier">T</span> <span class="identifier">v</span><span class="special">;</span>
|
||||||
<span class="identifier">T</span><span class="special">&</span> <span class="identifier">vref</span> <span class="special">=</span> <span class="identifier">v</span> <span class="special">;</span>
|
<span class="identifier">T</span><span class="special">&</span> <span class="identifier">vref</span> <span class="special">=</span> <span class="identifier">v</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="identifier">vref</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="identifier">vref</span><span class="special">);</span>
|
||||||
@ -246,7 +246,7 @@
|
|||||||
<p>
|
<p>
|
||||||
</p>
|
</p>
|
||||||
</blockquote></div>
|
</blockquote></div>
|
||||||
<div class="itemizedlist"><ul type="disc"><li>
|
<div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem">
|
||||||
If condition is true, same as:
|
If condition is true, same as:
|
||||||
</li></ul></div>
|
</li></ul></div>
|
||||||
<div class="blockquote"><blockquote class="blockquote">
|
<div class="blockquote"><blockquote class="blockquote">
|
||||||
@ -269,14 +269,14 @@
|
|||||||
<p>
|
<p>
|
||||||
</p>
|
</p>
|
||||||
</blockquote></div>
|
</blockquote></div>
|
||||||
<div class="itemizedlist"><ul type="disc"><li>
|
<div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem">
|
||||||
otherwise, same as:
|
otherwise, same as:
|
||||||
</li></ul></div>
|
</li></ul></div>
|
||||||
<div class="blockquote"><blockquote class="blockquote">
|
<div class="blockquote"><blockquote class="blockquote">
|
||||||
<p>
|
<p>
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
<code class="computeroutput"><span class="identifier">optional</span><span class="special"><</span><span class="identifier">T</span> <span class="special">[</span>#<span class="special">(</span><span class="keyword">not</span> <span class="identifier">a</span>
|
<code class="computeroutput"><span class="identifier">optional</span><span class="special"><</span><span class="identifier">T</span> <span class="special">[</span><span class="error">'</span><span class="special">(</span><span class="keyword">not</span> <span class="identifier">a</span>
|
||||||
<span class="identifier">ref</span><span class="special">)]>::</span><span class="identifier">optional</span><span class="special">()</span></code>
|
<span class="identifier">ref</span><span class="special">)]>::</span><span class="identifier">optional</span><span class="special">()</span></code>
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
@ -308,32 +308,32 @@
|
|||||||
<p>
|
<p>
|
||||||
</p>
|
</p>
|
||||||
</blockquote></div>
|
</blockquote></div>
|
||||||
<div class="itemizedlist"><ul type="disc">
|
<div class="itemizedlist"><ul class="itemizedlist" type="disc">
|
||||||
<li>
|
<li class="listitem">
|
||||||
<span class="bold"><strong>Effect:</strong></span> Copy-Constructs an <code class="computeroutput"><span class="identifier">optional</span></code>.
|
<span class="bold"><strong>Effect:</strong></span> Copy-Constructs an <code class="computeroutput"><span class="identifier">optional</span></code>.
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li class="listitem">
|
||||||
<span class="bold"><strong>Postconditions:</strong></span> If rhs is initialized,
|
<span class="bold"><strong>Postconditions:</strong></span> If rhs is initialized,
|
||||||
<code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code>
|
<code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code>
|
||||||
is initialized and its value is a <span class="emphasis"><em>copy</em></span> of the value
|
is initialized and its value is a <span class="emphasis"><em>copy</em></span> of the value
|
||||||
of <code class="computeroutput"><span class="identifier">rhs</span></code>; else <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> is uninitialized.
|
of <code class="computeroutput"><span class="identifier">rhs</span></code>; else <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> is uninitialized.
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li class="listitem">
|
||||||
<span class="bold"><strong>Throws:</strong></span> Whatever <code class="computeroutput"><span class="identifier">T</span><span class="special">::</span><span class="identifier">T</span><span class="special">(</span>
|
<span class="bold"><strong>Throws:</strong></span> Whatever <code class="computeroutput"><span class="identifier">T</span><span class="special">::</span><span class="identifier">T</span><span class="special">(</span>
|
||||||
<span class="identifier">T</span> <span class="keyword">const</span><span class="special">&</span> <span class="special">)</span></code> throws.
|
<span class="identifier">T</span> <span class="keyword">const</span><span class="special">&</span> <span class="special">)</span></code> throws.
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li class="listitem">
|
||||||
<span class="bold"><strong>Notes:</strong></span> If rhs is initialized, <code class="computeroutput"><span class="identifier">T</span><span class="special">::</span><span class="identifier">T</span><span class="special">(</span><span class="identifier">T</span> <span class="keyword">const</span><span class="special">&</span> <span class="special">)</span></code> is
|
<span class="bold"><strong>Notes:</strong></span> If rhs is initialized, <code class="computeroutput"><span class="identifier">T</span><span class="special">::</span><span class="identifier">T</span><span class="special">(</span><span class="identifier">T</span> <span class="keyword">const</span><span class="special">&</span> <span class="special">)</span></code> is
|
||||||
called.
|
called.
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li class="listitem">
|
||||||
<span class="bold"><strong>Exception Safety:</strong></span> Exceptions can only be
|
<span class="bold"><strong>Exception Safety:</strong></span> Exceptions can only be
|
||||||
thrown during <code class="computeroutput"><span class="identifier">T</span><span class="special">::</span><span class="identifier">T</span><span class="special">(</span> <span class="identifier">T</span>
|
thrown during <code class="computeroutput"><span class="identifier">T</span><span class="special">::</span><span class="identifier">T</span><span class="special">(</span> <span class="identifier">T</span>
|
||||||
<span class="keyword">const</span><span class="special">&</span>
|
<span class="keyword">const</span><span class="special">&</span>
|
||||||
<span class="special">);</span></code> in that case, this constructor
|
<span class="special">);</span></code> in that case, this constructor
|
||||||
has no effect.
|
has no effect.
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li class="listitem">
|
||||||
<span class="bold"><strong>Example:</strong></span><pre class="programlisting"><span class="identifier">optional</span><span class="special"><</span><span class="identifier">T</span><span class="special">></span> <span class="identifier">uninit</span> <span class="special">;</span>
|
<span class="bold"><strong>Example:</strong></span><pre class="programlisting"><span class="identifier">optional</span><span class="special"><</span><span class="identifier">T</span><span class="special">></span> <span class="identifier">uninit</span> <span class="special">;</span>
|
||||||
<span class="identifier">assert</span> <span class="special">(!</span><span class="identifier">uninit</span><span class="special">);</span>
|
<span class="identifier">assert</span> <span class="special">(!</span><span class="identifier">uninit</span><span class="special">);</span>
|
||||||
|
|
||||||
@ -360,11 +360,11 @@
|
|||||||
<p>
|
<p>
|
||||||
</p>
|
</p>
|
||||||
</blockquote></div>
|
</blockquote></div>
|
||||||
<div class="itemizedlist"><ul type="disc">
|
<div class="itemizedlist"><ul class="itemizedlist" type="disc">
|
||||||
<li>
|
<li class="listitem">
|
||||||
<span class="bold"><strong>Effect:</strong></span> Copy-Constructs an <code class="computeroutput"><span class="identifier">optional</span></code>.
|
<span class="bold"><strong>Effect:</strong></span> Copy-Constructs an <code class="computeroutput"><span class="identifier">optional</span></code>.
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li class="listitem">
|
||||||
<span class="bold"><strong>Postconditions:</strong></span> If <code class="computeroutput"><span class="identifier">rhs</span></code>
|
<span class="bold"><strong>Postconditions:</strong></span> If <code class="computeroutput"><span class="identifier">rhs</span></code>
|
||||||
is initialized, <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code>
|
is initialized, <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code>
|
||||||
is initialized and its value is another reference to the same object referenced
|
is initialized and its value is another reference to the same object referenced
|
||||||
@ -372,16 +372,16 @@
|
|||||||
else <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code>
|
else <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code>
|
||||||
is uninitialized.
|
is uninitialized.
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li class="listitem">
|
||||||
<span class="bold"><strong>Throws:</strong></span> Nothing.
|
<span class="bold"><strong>Throws:</strong></span> Nothing.
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li class="listitem">
|
||||||
<span class="bold"><strong>Notes:</strong></span> If <code class="computeroutput"><span class="identifier">rhs</span></code>
|
<span class="bold"><strong>Notes:</strong></span> If <code class="computeroutput"><span class="identifier">rhs</span></code>
|
||||||
is initialized, both <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code>
|
is initialized, both <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code>
|
||||||
and <code class="computeroutput"><span class="special">*</span><span class="identifier">rhs</span></code>
|
and <code class="computeroutput"><span class="special">*</span><span class="identifier">rhs</span></code>
|
||||||
will reefer to the same object (they alias).
|
will reefer to the same object (they alias).
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li class="listitem">
|
||||||
<span class="bold"><strong>Example:</strong></span><pre class="programlisting"><span class="identifier">optional</span><span class="special"><</span><span class="identifier">T</span><span class="special">&></span> <span class="identifier">uninit</span> <span class="special">;</span>
|
<span class="bold"><strong>Example:</strong></span><pre class="programlisting"><span class="identifier">optional</span><span class="special"><</span><span class="identifier">T</span><span class="special">&></span> <span class="identifier">uninit</span> <span class="special">;</span>
|
||||||
<span class="identifier">assert</span> <span class="special">(!</span><span class="identifier">uninit</span><span class="special">);</span>
|
<span class="identifier">assert</span> <span class="special">(!</span><span class="identifier">uninit</span><span class="special">);</span>
|
||||||
|
|
||||||
@ -417,11 +417,11 @@
|
|||||||
<p>
|
<p>
|
||||||
</p>
|
</p>
|
||||||
</blockquote></div>
|
</blockquote></div>
|
||||||
<div class="itemizedlist"><ul type="disc">
|
<div class="itemizedlist"><ul class="itemizedlist" type="disc">
|
||||||
<li>
|
<li class="listitem">
|
||||||
<span class="bold"><strong>Effect:</strong></span> Copy-Constructs an <code class="computeroutput"><span class="identifier">optional</span></code>.
|
<span class="bold"><strong>Effect:</strong></span> Copy-Constructs an <code class="computeroutput"><span class="identifier">optional</span></code>.
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li class="listitem">
|
||||||
<span class="bold"><strong>Postconditions:</strong></span> If <code class="computeroutput"><span class="identifier">rhs</span></code>
|
<span class="bold"><strong>Postconditions:</strong></span> If <code class="computeroutput"><span class="identifier">rhs</span></code>
|
||||||
is initialized, <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code>
|
is initialized, <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code>
|
||||||
is initialized and its value is a <span class="emphasis"><em>copy</em></span> of the value
|
is initialized and its value is a <span class="emphasis"><em>copy</em></span> of the value
|
||||||
@ -429,25 +429,25 @@
|
|||||||
else <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code>
|
else <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code>
|
||||||
is uninitialized.
|
is uninitialized.
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li class="listitem">
|
||||||
<span class="bold"><strong>Throws:</strong></span> Whatever <code class="computeroutput"><span class="identifier">T</span><span class="special">::</span><span class="identifier">T</span><span class="special">(</span>
|
<span class="bold"><strong>Throws:</strong></span> Whatever <code class="computeroutput"><span class="identifier">T</span><span class="special">::</span><span class="identifier">T</span><span class="special">(</span>
|
||||||
<span class="identifier">U</span> <span class="keyword">const</span><span class="special">&</span> <span class="special">)</span></code> throws.
|
<span class="identifier">U</span> <span class="keyword">const</span><span class="special">&</span> <span class="special">)</span></code> throws.
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li class="listitem">
|
||||||
<span class="bold"><strong>Notes: </strong></span><code class="computeroutput"><span class="identifier">T</span><span class="special">::</span><span class="identifier">T</span><span class="special">(</span>
|
<span class="bold"><strong>Notes: </strong></span><code class="computeroutput"><span class="identifier">T</span><span class="special">::</span><span class="identifier">T</span><span class="special">(</span>
|
||||||
<span class="identifier">U</span> <span class="keyword">const</span><span class="special">&</span> <span class="special">)</span></code> is
|
<span class="identifier">U</span> <span class="keyword">const</span><span class="special">&</span> <span class="special">)</span></code> is
|
||||||
called if <code class="computeroutput"><span class="identifier">rhs</span></code> is initialized,
|
called if <code class="computeroutput"><span class="identifier">rhs</span></code> is initialized,
|
||||||
which requires a valid conversion from <code class="computeroutput"><span class="identifier">U</span></code>
|
which requires a valid conversion from <code class="computeroutput"><span class="identifier">U</span></code>
|
||||||
to <code class="computeroutput"><span class="identifier">T</span></code>.
|
to <code class="computeroutput"><span class="identifier">T</span></code>.
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li class="listitem">
|
||||||
<span class="bold"><strong>Exception Safety:</strong></span> Exceptions can only be
|
<span class="bold"><strong>Exception Safety:</strong></span> Exceptions can only be
|
||||||
thrown during <code class="computeroutput"><span class="identifier">T</span><span class="special">::</span><span class="identifier">T</span><span class="special">(</span> <span class="identifier">U</span>
|
thrown during <code class="computeroutput"><span class="identifier">T</span><span class="special">::</span><span class="identifier">T</span><span class="special">(</span> <span class="identifier">U</span>
|
||||||
<span class="keyword">const</span><span class="special">&</span>
|
<span class="keyword">const</span><span class="special">&</span>
|
||||||
<span class="special">);</span></code> in that case, this constructor
|
<span class="special">);</span></code> in that case, this constructor
|
||||||
has no effect.
|
has no effect.
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li class="listitem">
|
||||||
<span class="bold"><strong>Example:</strong></span><pre class="programlisting"><span class="identifier">optional</span><span class="special"><</span><span class="keyword">double</span><span class="special">></span> <span class="identifier">x</span><span class="special">(</span><span class="number">123.4</span><span class="special">);</span>
|
<span class="bold"><strong>Example:</strong></span><pre class="programlisting"><span class="identifier">optional</span><span class="special"><</span><span class="keyword">double</span><span class="special">></span> <span class="identifier">x</span><span class="special">(</span><span class="number">123.4</span><span class="special">);</span>
|
||||||
<span class="identifier">assert</span> <span class="special">(</span> <span class="special">*</span><span class="identifier">x</span> <span class="special">==</span> <span class="number">123.4</span> <span class="special">)</span> <span class="special">;</span>
|
<span class="identifier">assert</span> <span class="special">(</span> <span class="special">*</span><span class="identifier">x</span> <span class="special">==</span> <span class="number">123.4</span> <span class="special">)</span> <span class="special">;</span>
|
||||||
|
|
||||||
@ -483,31 +483,31 @@
|
|||||||
<p>
|
<p>
|
||||||
</p>
|
</p>
|
||||||
</blockquote></div>
|
</blockquote></div>
|
||||||
<div class="itemizedlist"><ul type="disc">
|
<div class="itemizedlist"><ul class="itemizedlist" type="disc">
|
||||||
<li>
|
<li class="listitem">
|
||||||
<span class="bold"><strong>Effect:</strong></span> Constructs an <code class="computeroutput"><span class="identifier">optional</span></code>
|
<span class="bold"><strong>Effect:</strong></span> Constructs an <code class="computeroutput"><span class="identifier">optional</span></code>
|
||||||
with a value of <code class="computeroutput"><span class="identifier">T</span></code> obtained
|
with a value of <code class="computeroutput"><span class="identifier">T</span></code> obtained
|
||||||
from the factory.
|
from the factory.
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li class="listitem">
|
||||||
<span class="bold"><strong>Postconditions: </strong></span><code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> is <span class="underline">initialized</span>
|
<span class="bold"><strong>Postconditions: </strong></span><code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> is <span class="underline">initialized</span>
|
||||||
and its value is <span class="emphasis"><em>directly given</em></span> from the factory <code class="computeroutput"><span class="identifier">f</span></code> (i.e., the value <span class="underline">is
|
and its value is <span class="emphasis"><em>directly given</em></span> from the factory <code class="computeroutput"><span class="identifier">f</span></code> (i.e., the value <span class="underline">is
|
||||||
not copied</span>).
|
not copied</span>).
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li class="listitem">
|
||||||
<span class="bold"><strong>Throws:</strong></span> Whatever the <code class="computeroutput"><span class="identifier">T</span></code>
|
<span class="bold"><strong>Throws:</strong></span> Whatever the <code class="computeroutput"><span class="identifier">T</span></code>
|
||||||
constructor called by the factory throws.
|
constructor called by the factory throws.
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li class="listitem">
|
||||||
<span class="bold"><strong>Notes:</strong></span> See <a class="link" href="../index.html#optional_in_place_factories">In-Place
|
<span class="bold"><strong>Notes:</strong></span> See <a class="link" href="in_place_factories.html" title="In-Place Factories">In-Place
|
||||||
Factories</a>
|
Factories</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li class="listitem">
|
||||||
<span class="bold"><strong>Exception Safety:</strong></span> Exceptions can only be
|
<span class="bold"><strong>Exception Safety:</strong></span> Exceptions can only be
|
||||||
thrown during the call to the <code class="computeroutput"><span class="identifier">T</span></code>
|
thrown during the call to the <code class="computeroutput"><span class="identifier">T</span></code>
|
||||||
constructor used by the factory; in that case, this constructor has no effect.
|
constructor used by the factory; in that case, this constructor has no effect.
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li class="listitem">
|
||||||
<span class="bold"><strong>Example:</strong></span><pre class="programlisting"><span class="keyword">class</span> <span class="identifier">C</span> <span class="special">{</span> <span class="identifier">C</span> <span class="special">(</span> <span class="keyword">char</span><span class="special">,</span> <span class="keyword">double</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="bold"><strong>Example:</strong></span><pre class="programlisting"><span class="keyword">class</span> <span class="identifier">C</span> <span class="special">{</span> <span class="identifier">C</span> <span class="special">(</span> <span class="keyword">char</span><span class="special">,</span> <span class="keyword">double</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="identifier">C</span> <span class="identifier">v</span><span class="special">(</span><span class="char">'A'</span><span class="special">,</span><span class="number">123.4</span><span class="special">,</span><span class="string">"hello"</span><span class="special">);</span>
|
<span class="identifier">C</span> <span class="identifier">v</span><span class="special">(</span><span class="char">'A'</span><span class="special">,</span><span class="number">123.4</span><span class="special">,</span><span class="string">"hello"</span><span class="special">);</span>
|
||||||
@ -538,25 +538,25 @@
|
|||||||
<p>
|
<p>
|
||||||
</p>
|
</p>
|
||||||
</blockquote></div>
|
</blockquote></div>
|
||||||
<div class="itemizedlist"><ul type="disc">
|
<div class="itemizedlist"><ul class="itemizedlist" type="disc">
|
||||||
<li>
|
<li class="listitem">
|
||||||
<span class="bold"><strong>Effect:</strong></span> Assigns the value <code class="computeroutput"><span class="identifier">rhs</span></code> to an <code class="computeroutput"><span class="identifier">optional</span></code>.
|
<span class="bold"><strong>Effect:</strong></span> Assigns the value <code class="computeroutput"><span class="identifier">rhs</span></code> to an <code class="computeroutput"><span class="identifier">optional</span></code>.
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li class="listitem">
|
||||||
<span class="bold"><strong>Postconditions: </strong></span><code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> is initialized and its value is a <span class="emphasis"><em>copy</em></span>
|
<span class="bold"><strong>Postconditions: </strong></span><code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> is initialized and its value is a <span class="emphasis"><em>copy</em></span>
|
||||||
of <code class="computeroutput"><span class="identifier">rhs</span></code>.
|
of <code class="computeroutput"><span class="identifier">rhs</span></code>.
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li class="listitem">
|
||||||
<span class="bold"><strong>Throws:</strong></span> Whatever <code class="computeroutput"><span class="identifier">T</span><span class="special">::</span><span class="keyword">operator</span><span class="special">=(</span> <span class="identifier">T</span> <span class="keyword">const</span><span class="special">&</span> <span class="special">)</span></code> or
|
<span class="bold"><strong>Throws:</strong></span> Whatever <code class="computeroutput"><span class="identifier">T</span><span class="special">::</span><span class="keyword">operator</span><span class="special">=(</span> <span class="identifier">T</span> <span class="keyword">const</span><span class="special">&</span> <span class="special">)</span></code> or
|
||||||
<code class="computeroutput"><span class="identifier">T</span><span class="special">::</span><span class="identifier">T</span><span class="special">(</span><span class="identifier">T</span>
|
<code class="computeroutput"><span class="identifier">T</span><span class="special">::</span><span class="identifier">T</span><span class="special">(</span><span class="identifier">T</span>
|
||||||
<span class="keyword">const</span><span class="special">&)</span></code>
|
<span class="keyword">const</span><span class="special">&)</span></code>
|
||||||
throws.
|
throws.
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li class="listitem">
|
||||||
<span class="bold"><strong>Notes:</strong></span> If <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> was initialized, <code class="computeroutput"><span class="identifier">T</span></code>'s
|
<span class="bold"><strong>Notes:</strong></span> If <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> was initialized, <code class="computeroutput"><span class="identifier">T</span></code>'s
|
||||||
assignment operator is used, otherwise, its copy-constructor is used.
|
assignment operator is used, otherwise, its copy-constructor is used.
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li class="listitem">
|
||||||
<span class="bold"><strong>Exception Safety:</strong></span> In the event of an exception,
|
<span class="bold"><strong>Exception Safety:</strong></span> In the event of an exception,
|
||||||
the initialization state of <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> is unchanged and its value unspecified
|
the initialization state of <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> is unchanged and its value unspecified
|
||||||
as far as <code class="computeroutput"><span class="identifier">optional</span></code> is concerned
|
as far as <code class="computeroutput"><span class="identifier">optional</span></code> is concerned
|
||||||
@ -565,7 +565,7 @@
|
|||||||
is initially uninitialized and <code class="computeroutput"><span class="identifier">T</span></code>'s
|
is initially uninitialized and <code class="computeroutput"><span class="identifier">T</span></code>'s
|
||||||
<span class="emphasis"><em>copy constructor</em></span> fails, <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> is left properly uninitialized.
|
<span class="emphasis"><em>copy constructor</em></span> fails, <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> is left properly uninitialized.
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li class="listitem">
|
||||||
<span class="bold"><strong>Example:</strong></span><pre class="programlisting"><span class="identifier">T</span> <span class="identifier">x</span><span class="special">;</span>
|
<span class="bold"><strong>Example:</strong></span><pre class="programlisting"><span class="identifier">T</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">def</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">def</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="identifier">x</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="identifier">opt</span><span class="special">(</span><span class="identifier">x</span><span class="special">)</span> <span class="special">;</span>
|
||||||
@ -594,20 +594,20 @@
|
|||||||
<p>
|
<p>
|
||||||
</p>
|
</p>
|
||||||
</blockquote></div>
|
</blockquote></div>
|
||||||
<div class="itemizedlist"><ul type="disc">
|
<div class="itemizedlist"><ul class="itemizedlist" type="disc">
|
||||||
<li>
|
<li class="listitem">
|
||||||
<span class="bold"><strong>Effect:</strong></span> (Re)binds thee wrapped reference.
|
<span class="bold"><strong>Effect:</strong></span> (Re)binds thee wrapped reference.
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li class="listitem">
|
||||||
<span class="bold"><strong>Postconditions: </strong></span><code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> is initialized and it references the
|
<span class="bold"><strong>Postconditions: </strong></span><code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> is initialized and it references the
|
||||||
same object referenced by <code class="computeroutput"><span class="identifier">rhs</span></code>.
|
same object referenced by <code class="computeroutput"><span class="identifier">rhs</span></code>.
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li class="listitem">
|
||||||
<span class="bold"><strong>Notes:</strong></span> If <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> was initialized, is is <span class="emphasis"><em>rebound</em></span>
|
<span class="bold"><strong>Notes:</strong></span> If <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> was initialized, is is <span class="emphasis"><em>rebound</em></span>
|
||||||
to the new object. See <a class="link" href="../index.html#optional_refassign">here</a> for
|
to the new object. See <a class="link" href="rebinding_semantics_for_assignment_of_optional_references.html" title="Rebinding semantics for assignment of optional references">here</a>
|
||||||
details on this behavior.
|
for details on this behavior.
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li class="listitem">
|
||||||
<span class="bold"><strong>Example:</strong></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="bold"><strong>Example:</strong></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="identifier">T</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="identifier">T</span><span class="special">&</span> <span class="identifier">ra</span> <span class="special">=</span> <span class="identifier">a</span> <span class="special">;</span>
|
||||||
@ -645,29 +645,29 @@
|
|||||||
<p>
|
<p>
|
||||||
</p>
|
</p>
|
||||||
</blockquote></div>
|
</blockquote></div>
|
||||||
<div class="itemizedlist"><ul type="disc">
|
<div class="itemizedlist"><ul class="itemizedlist" type="disc">
|
||||||
<li>
|
<li class="listitem">
|
||||||
<span class="bold"><strong>Effect:</strong></span> Assigns another <code class="computeroutput"><span class="identifier">optional</span></code>
|
<span class="bold"><strong>Effect:</strong></span> Assigns another <code class="computeroutput"><span class="identifier">optional</span></code>
|
||||||
to an <code class="computeroutput"><span class="identifier">optional</span></code>.
|
to an <code class="computeroutput"><span class="identifier">optional</span></code>.
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li class="listitem">
|
||||||
<span class="bold"><strong>Postconditions:</strong></span> If <code class="computeroutput"><span class="identifier">rhs</span></code>
|
<span class="bold"><strong>Postconditions:</strong></span> If <code class="computeroutput"><span class="identifier">rhs</span></code>
|
||||||
is initialized, <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code>
|
is initialized, <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code>
|
||||||
is initialized and its value is a <span class="emphasis"><em>copy</em></span> of the value
|
is initialized and its value is a <span class="emphasis"><em>copy</em></span> of the value
|
||||||
of <code class="computeroutput"><span class="identifier">rhs</span></code>; else <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> is uninitialized.
|
of <code class="computeroutput"><span class="identifier">rhs</span></code>; else <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> is uninitialized.
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li class="listitem">
|
||||||
<span class="bold"><strong>Throws:</strong></span> Whatever <code class="computeroutput"><span class="identifier">T</span><span class="special">::</span><span class="keyword">operator</span><span class="special">(</span> <span class="identifier">T</span> <span class="keyword">const</span><span class="special">&)</span></code> or <code class="computeroutput"><span class="identifier">T</span><span class="special">::</span><span class="identifier">T</span><span class="special">(</span>
|
<span class="bold"><strong>Throws:</strong></span> Whatever <code class="computeroutput"><span class="identifier">T</span><span class="special">::</span><span class="keyword">operator</span><span class="special">(</span> <span class="identifier">T</span> <span class="keyword">const</span><span class="special">&)</span></code> or <code class="computeroutput"><span class="identifier">T</span><span class="special">::</span><span class="identifier">T</span><span class="special">(</span>
|
||||||
<span class="identifier">T</span> <span class="keyword">const</span><span class="special">&</span> <span class="special">)</span></code> throws.
|
<span class="identifier">T</span> <span class="keyword">const</span><span class="special">&</span> <span class="special">)</span></code> throws.
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li class="listitem">
|
||||||
<span class="bold"><strong>Notes:</strong></span> If both <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> and <code class="computeroutput"><span class="identifier">rhs</span></code>
|
<span class="bold"><strong>Notes:</strong></span> If both <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> and <code class="computeroutput"><span class="identifier">rhs</span></code>
|
||||||
are initially initialized, <code class="computeroutput"><span class="identifier">T</span></code>'s
|
are initially initialized, <code class="computeroutput"><span class="identifier">T</span></code>'s
|
||||||
<span class="emphasis"><em>assignment operator</em></span> is used. If <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> is initially initialized but <code class="computeroutput"><span class="identifier">rhs</span></code> is uninitialized, <code class="computeroutput"><span class="identifier">T</span></code>'s
|
<span class="emphasis"><em>assignment operator</em></span> is used. If <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> is initially initialized but <code class="computeroutput"><span class="identifier">rhs</span></code> is uninitialized, <code class="computeroutput"><span class="identifier">T</span></code>'s
|
||||||
[destructor] is called. If <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> is initially uninitialized but <code class="computeroutput"><span class="identifier">rhs</span></code> is initialized, <code class="computeroutput"><span class="identifier">T</span></code>'s
|
[destructor] is called. If <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> is initially uninitialized but <code class="computeroutput"><span class="identifier">rhs</span></code> is initialized, <code class="computeroutput"><span class="identifier">T</span></code>'s
|
||||||
<span class="emphasis"><em>copy constructor</em></span> is called.
|
<span class="emphasis"><em>copy constructor</em></span> is called.
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li class="listitem">
|
||||||
<span class="bold"><strong>Exception Safety:</strong></span> In the event of an exception,
|
<span class="bold"><strong>Exception Safety:</strong></span> In the event of an exception,
|
||||||
the initialization state of <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> is unchanged and its value unspecified
|
the initialization state of <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> is unchanged and its value unspecified
|
||||||
as far as optional is concerned (it is up to <code class="computeroutput"><span class="identifier">T</span></code>'s
|
as far as optional is concerned (it is up to <code class="computeroutput"><span class="identifier">T</span></code>'s
|
||||||
@ -676,7 +676,7 @@
|
|||||||
is initially uninitialized and <code class="computeroutput"><span class="identifier">T</span></code>'s
|
is initially uninitialized and <code class="computeroutput"><span class="identifier">T</span></code>'s
|
||||||
<span class="emphasis"><em>copy constructor</em></span> fails, <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> is left properly uninitialized.
|
<span class="emphasis"><em>copy constructor</em></span> fails, <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> is left properly uninitialized.
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li class="listitem">
|
||||||
<span class="bold"><strong>Example:</strong></span><pre class="programlisting"><span class="identifier">T</span> <span class="identifier">v</span><span class="special">;</span>
|
<span class="bold"><strong>Example:</strong></span><pre class="programlisting"><span class="identifier">T</span> <span class="identifier">v</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="identifier">v</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="identifier">v</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">def</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">def</span> <span class="special">;</span>
|
||||||
@ -700,20 +700,20 @@
|
|||||||
<p>
|
<p>
|
||||||
</p>
|
</p>
|
||||||
</blockquote></div>
|
</blockquote></div>
|
||||||
<div class="itemizedlist"><ul type="disc">
|
<div class="itemizedlist"><ul class="itemizedlist" type="disc">
|
||||||
<li>
|
<li class="listitem">
|
||||||
<span class="bold"><strong>Effect:</strong></span> (Re)binds thee wrapped reference.
|
<span class="bold"><strong>Effect:</strong></span> (Re)binds thee wrapped reference.
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li class="listitem">
|
||||||
<span class="bold"><strong>Postconditions:</strong></span> If <code class="computeroutput"><span class="special">*</span><span class="identifier">rhs</span></code> is initialized, <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> is initialized and it references the
|
<span class="bold"><strong>Postconditions:</strong></span> If <code class="computeroutput"><span class="special">*</span><span class="identifier">rhs</span></code> is initialized, <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> is initialized and it references the
|
||||||
same object referenced by <code class="computeroutput"><span class="special">*</span><span class="identifier">rhs</span></code>; otherwise, <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> is uninitialized (and references no object).
|
same object referenced by <code class="computeroutput"><span class="special">*</span><span class="identifier">rhs</span></code>; otherwise, <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> is uninitialized (and references no object).
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li class="listitem">
|
||||||
<span class="bold"><strong>Notes:</strong></span> If <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> was initialized and so is *rhs, this
|
<span class="bold"><strong>Notes:</strong></span> If <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> was initialized and so is *rhs, this
|
||||||
is is <span class="emphasis"><em>rebound</em></span> to the new object. See <a class="link" href="../index.html#optional_refassign">here</a>
|
is is <span class="emphasis"><em>rebound</em></span> to the new object. See <a class="link" href="rebinding_semantics_for_assignment_of_optional_references.html" title="Rebinding semantics for assignment of optional references">here</a>
|
||||||
for details on this behavior.
|
for details on this behavior.
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li class="listitem">
|
||||||
<span class="bold"><strong>Example:</strong></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="bold"><strong>Example:</strong></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="identifier">T</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="identifier">T</span><span class="special">&</span> <span class="identifier">ra</span> <span class="special">=</span> <span class="identifier">a</span> <span class="special">;</span>
|
||||||
@ -750,25 +750,25 @@
|
|||||||
<p>
|
<p>
|
||||||
</p>
|
</p>
|
||||||
</blockquote></div>
|
</blockquote></div>
|
||||||
<div class="itemizedlist"><ul type="disc">
|
<div class="itemizedlist"><ul class="itemizedlist" type="disc">
|
||||||
<li>
|
<li class="listitem">
|
||||||
<span class="bold"><strong>Effect:</strong></span> Assigns another convertible optional
|
<span class="bold"><strong>Effect:</strong></span> Assigns another convertible optional
|
||||||
to an optional.
|
to an optional.
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li class="listitem">
|
||||||
<span class="bold"><strong>Postconditions:</strong></span> If <code class="computeroutput"><span class="identifier">rhs</span></code>
|
<span class="bold"><strong>Postconditions:</strong></span> If <code class="computeroutput"><span class="identifier">rhs</span></code>
|
||||||
is initialized, <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code>
|
is initialized, <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code>
|
||||||
is initialized and its value is a <span class="emphasis"><em>copy</em></span> of the value
|
is initialized and its value is a <span class="emphasis"><em>copy</em></span> of the value
|
||||||
of <code class="computeroutput"><span class="identifier">rhs</span></code><span class="emphasis"><em>converted</em></span>
|
of <code class="computeroutput"><span class="identifier">rhs</span></code><span class="emphasis"><em>converted</em></span>
|
||||||
to type <code class="computeroutput"><span class="identifier">T</span></code>; else <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> is uninitialized.
|
to type <code class="computeroutput"><span class="identifier">T</span></code>; else <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> is uninitialized.
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li class="listitem">
|
||||||
<span class="bold"><strong>Throws:</strong></span> Whatever <code class="computeroutput"><span class="identifier">T</span><span class="special">::</span><span class="keyword">operator</span><span class="special">=(</span> <span class="identifier">U</span> <span class="keyword">const</span><span class="special">&</span> <span class="special">)</span></code> or
|
<span class="bold"><strong>Throws:</strong></span> Whatever <code class="computeroutput"><span class="identifier">T</span><span class="special">::</span><span class="keyword">operator</span><span class="special">=(</span> <span class="identifier">U</span> <span class="keyword">const</span><span class="special">&</span> <span class="special">)</span></code> or
|
||||||
<code class="computeroutput"><span class="identifier">T</span><span class="special">::</span><span class="identifier">T</span><span class="special">(</span> <span class="identifier">U</span>
|
<code class="computeroutput"><span class="identifier">T</span><span class="special">::</span><span class="identifier">T</span><span class="special">(</span> <span class="identifier">U</span>
|
||||||
<span class="keyword">const</span><span class="special">&</span>
|
<span class="keyword">const</span><span class="special">&</span>
|
||||||
<span class="special">)</span></code> throws.
|
<span class="special">)</span></code> throws.
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li class="listitem">
|
||||||
<span class="bold"><strong>Notes:</strong></span> If both <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> and rhs are initially initialized, <code class="computeroutput"><span class="identifier">T</span></code>'s <span class="emphasis"><em>assignment operator</em></span>
|
<span class="bold"><strong>Notes:</strong></span> If both <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> and rhs are initially initialized, <code class="computeroutput"><span class="identifier">T</span></code>'s <span class="emphasis"><em>assignment operator</em></span>
|
||||||
(from <code class="computeroutput"><span class="identifier">U</span></code>) is used. If <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> is initially
|
(from <code class="computeroutput"><span class="identifier">U</span></code>) is used. If <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> is initially
|
||||||
initialized but <code class="computeroutput"><span class="identifier">rhs</span></code> is uninitialized,
|
initialized but <code class="computeroutput"><span class="identifier">rhs</span></code> is uninitialized,
|
||||||
@ -778,7 +778,7 @@
|
|||||||
<span class="emphasis"><em>converting constructor</em></span> (from <code class="computeroutput"><span class="identifier">U</span></code>)
|
<span class="emphasis"><em>converting constructor</em></span> (from <code class="computeroutput"><span class="identifier">U</span></code>)
|
||||||
is called.
|
is called.
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li class="listitem">
|
||||||
<span class="bold"><strong>Exception Safety:</strong></span> In the event of an exception,
|
<span class="bold"><strong>Exception Safety:</strong></span> In the event of an exception,
|
||||||
the initialization state of <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> is unchanged and its value unspecified
|
the initialization state of <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> is unchanged and its value unspecified
|
||||||
as far as optional is concerned (it is up to <code class="computeroutput"><span class="identifier">T</span></code>'s
|
as far as optional is concerned (it is up to <code class="computeroutput"><span class="identifier">T</span></code>'s
|
||||||
@ -787,7 +787,7 @@
|
|||||||
is initially uninitialized and <code class="computeroutput"><span class="identifier">T</span></code>'s
|
is initially uninitialized and <code class="computeroutput"><span class="identifier">T</span></code>'s
|
||||||
converting constructor fails, <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> is left properly uninitialized.
|
converting constructor fails, <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> is left properly uninitialized.
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li class="listitem">
|
||||||
<span class="bold"><strong>Example:</strong></span><pre class="programlisting"><span class="identifier">T</span> <span class="identifier">v</span><span class="special">;</span>
|
<span class="bold"><strong>Example:</strong></span><pre class="programlisting"><span class="identifier">T</span> <span class="identifier">v</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">opt0</span><span class="special">(</span><span class="identifier">v</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">opt0</span><span class="special">(</span><span class="identifier">v</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="identifier">opt1</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="identifier">opt1</span><span class="special">;</span>
|
||||||
@ -812,7 +812,7 @@
|
|||||||
<p>
|
<p>
|
||||||
</p>
|
</p>
|
||||||
</blockquote></div>
|
</blockquote></div>
|
||||||
<div class="itemizedlist"><ul type="disc"><li>
|
<div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem">
|
||||||
<span class="bold"><strong>Deprecated:</strong></span> same as <code class="computeroutput"><span class="keyword">operator</span><span class="special">=</span> <span class="special">(</span> <span class="identifier">T</span>
|
<span class="bold"><strong>Deprecated:</strong></span> same as <code class="computeroutput"><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="keyword">const</span><span class="special">&</span>
|
||||||
<span class="identifier">v</span><span class="special">)</span> <span class="special">;</span></code>
|
<span class="identifier">v</span><span class="special">)</span> <span class="special">;</span></code>
|
||||||
@ -831,7 +831,7 @@
|
|||||||
<p>
|
<p>
|
||||||
</p>
|
</p>
|
||||||
</blockquote></div>
|
</blockquote></div>
|
||||||
<div class="itemizedlist"><ul type="disc"><li>
|
<div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem">
|
||||||
<span class="bold"><strong>Deprecated:</strong></span> Same as <code class="computeroutput"><span class="keyword">operator</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>
|
<span class="bold"><strong>Deprecated:</strong></span> Same as <code class="computeroutput"><span class="keyword">operator</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></ul></div>
|
</li></ul></div>
|
||||||
<p>
|
<p>
|
||||||
@ -902,21 +902,21 @@
|
|||||||
<p>
|
<p>
|
||||||
</p>
|
</p>
|
||||||
</blockquote></div>
|
</blockquote></div>
|
||||||
<div class="itemizedlist"><ul type="disc">
|
<div class="itemizedlist"><ul class="itemizedlist" type="disc">
|
||||||
<li>
|
<li class="listitem">
|
||||||
<span class="bold"><strong>Requirements:</strong></span><code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> is initialized
|
<span class="bold"><strong>Requirements:</strong></span><code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> is initialized
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li class="listitem">
|
||||||
<span class="bold"><strong>Returns:</strong></span> A reference to the contained value
|
<span class="bold"><strong>Returns:</strong></span> A reference to the contained value
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li class="listitem">
|
||||||
<span class="bold"><strong>Throws:</strong></span> Nothing.
|
<span class="bold"><strong>Throws:</strong></span> Nothing.
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li class="listitem">
|
||||||
<span class="bold"><strong>Notes:</strong></span> The requirement is asserted via
|
<span class="bold"><strong>Notes:</strong></span> The requirement is asserted via
|
||||||
<code class="computeroutput"><span class="identifier">BOOST_ASSERT</span><span class="special">()</span></code>.
|
<code class="computeroutput"><span class="identifier">BOOST_ASSERT</span><span class="special">()</span></code>.
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li class="listitem">
|
||||||
<span class="bold"><strong>Example:</strong></span><pre class="programlisting"><span class="identifier">T</span> <span class="identifier">v</span> <span class="special">;</span>
|
<span class="bold"><strong>Example:</strong></span><pre class="programlisting"><span class="identifier">T</span> <span class="identifier">v</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="identifier">v</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="identifier">v</span> <span class="special">);</span>
|
||||||
<span class="identifier">T</span> <span class="keyword">const</span><span class="special">&</span> <span class="identifier">u</span> <span class="special">=</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="identifier">u</span> <span class="special">=</span> <span class="special">*</span><span class="identifier">opt</span><span class="special">;</span>
|
||||||
@ -982,15 +982,15 @@
|
|||||||
<p>
|
<p>
|
||||||
</p>
|
</p>
|
||||||
</blockquote></div>
|
</blockquote></div>
|
||||||
<div class="itemizedlist"><ul type="disc">
|
<div class="itemizedlist"><ul class="itemizedlist" type="disc">
|
||||||
<li>
|
<li class="listitem">
|
||||||
<span class="bold"><strong>Returns:</strong></span> A reference to the contained value,
|
<span class="bold"><strong>Returns:</strong></span> A reference to the contained value,
|
||||||
if any, or <code class="computeroutput"><span class="keyword">default</span></code>.
|
if any, or <code class="computeroutput"><span class="keyword">default</span></code>.
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li class="listitem">
|
||||||
<span class="bold"><strong>Throws:</strong></span> Nothing.
|
<span class="bold"><strong>Throws:</strong></span> Nothing.
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li class="listitem">
|
||||||
<span class="bold"><strong>Example:</strong></span><pre class="programlisting"><span class="identifier">T</span> <span class="identifier">v</span><span class="special">,</span> <span class="identifier">z</span> <span class="special">;</span>
|
<span class="bold"><strong>Example:</strong></span><pre class="programlisting"><span class="identifier">T</span> <span class="identifier">v</span><span class="special">,</span> <span class="identifier">z</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">def</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">def</span><span class="special">;</span>
|
||||||
<span class="identifier">T</span> <span class="keyword">const</span><span class="special">&</span> <span class="identifier">y</span> <span class="special">=</span> <span class="identifier">def</span><span class="special">.</span><span class="identifier">get_value_or</span><span class="special">(</span><span class="identifier">z</span><span class="special">);</span>
|
<span class="identifier">T</span> <span class="keyword">const</span><span class="special">&</span> <span class="identifier">y</span> <span class="special">=</span> <span class="identifier">def</span><span class="special">.</span><span class="identifier">get_value_or</span><span class="special">(</span><span class="identifier">z</span><span class="special">);</span>
|
||||||
@ -1068,22 +1068,22 @@
|
|||||||
<p>
|
<p>
|
||||||
</p>
|
</p>
|
||||||
</blockquote></div>
|
</blockquote></div>
|
||||||
<div class="itemizedlist"><ul type="disc">
|
<div class="itemizedlist"><ul class="itemizedlist" type="disc">
|
||||||
<li>
|
<li class="listitem">
|
||||||
<span class="bold"><strong>Requirements: </strong></span><code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> is initialized
|
<span class="bold"><strong>Requirements: </strong></span><code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> is initialized
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li class="listitem">
|
||||||
<span class="bold"><strong>Returns:</strong></span><span class="underline">The</span>
|
<span class="bold"><strong>Returns:</strong></span><span class="underline">The</span>
|
||||||
reference contained.
|
reference contained.
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li class="listitem">
|
||||||
<span class="bold"><strong>Throws:</strong></span> Nothing.
|
<span class="bold"><strong>Throws:</strong></span> Nothing.
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li class="listitem">
|
||||||
<span class="bold"><strong>Notes:</strong></span> The requirement is asserted via
|
<span class="bold"><strong>Notes:</strong></span> The requirement is asserted via
|
||||||
<code class="computeroutput"><span class="identifier">BOOST_ASSERT</span><span class="special">()</span></code>.
|
<code class="computeroutput"><span class="identifier">BOOST_ASSERT</span><span class="special">()</span></code>.
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li class="listitem">
|
||||||
<span class="bold"><strong>Example:</strong></span><pre class="programlisting"><span class="identifier">T</span> <span class="identifier">v</span> <span class="special">;</span>
|
<span class="bold"><strong>Example:</strong></span><pre class="programlisting"><span class="identifier">T</span> <span class="identifier">v</span> <span class="special">;</span>
|
||||||
<span class="identifier">T</span><span class="special">&</span> <span class="identifier">vref</span> <span class="special">=</span> <span class="identifier">v</span> <span class="special">;</span>
|
<span class="identifier">T</span><span class="special">&</span> <span class="identifier">vref</span> <span class="special">=</span> <span class="identifier">v</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="identifier">vref</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="identifier">vref</span> <span class="special">);</span>
|
||||||
@ -1143,20 +1143,20 @@
|
|||||||
<p>
|
<p>
|
||||||
</p>
|
</p>
|
||||||
</blockquote></div>
|
</blockquote></div>
|
||||||
<div class="itemizedlist"><ul type="disc">
|
<div class="itemizedlist"><ul class="itemizedlist" type="disc">
|
||||||
<li>
|
<li class="listitem">
|
||||||
<span class="bold"><strong>Returns:</strong></span> If <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> is initialized, a pointer to the contained
|
<span class="bold"><strong>Returns:</strong></span> If <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> is initialized, a pointer to the contained
|
||||||
value; else <code class="computeroutput"><span class="number">0</span></code> (<span class="emphasis"><em>null</em></span>).
|
value; else <code class="computeroutput"><span class="number">0</span></code> (<span class="emphasis"><em>null</em></span>).
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li class="listitem">
|
||||||
<span class="bold"><strong>Throws:</strong></span> Nothing.
|
<span class="bold"><strong>Throws:</strong></span> Nothing.
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li class="listitem">
|
||||||
<span class="bold"><strong>Notes:</strong></span> The contained value is permanently
|
<span class="bold"><strong>Notes:</strong></span> The contained value is permanently
|
||||||
stored within <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code>,
|
stored within <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code>,
|
||||||
so you should not hold nor delete this pointer
|
so you should not hold nor delete this pointer
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li class="listitem">
|
||||||
<span class="bold"><strong>Example:</strong></span><pre class="programlisting"><span class="identifier">T</span> <span class="identifier">v</span><span class="special">;</span>
|
<span class="bold"><strong>Example:</strong></span><pre class="programlisting"><span class="identifier">T</span> <span class="identifier">v</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="identifier">v</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="identifier">v</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="identifier">copt</span><span class="special">(</span><span class="identifier">v</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="identifier">copt</span><span class="special">(</span><span class="identifier">v</span><span class="special">);</span>
|
||||||
@ -1194,21 +1194,21 @@
|
|||||||
<p>
|
<p>
|
||||||
</p>
|
</p>
|
||||||
</blockquote></div>
|
</blockquote></div>
|
||||||
<div class="itemizedlist"><ul type="disc">
|
<div class="itemizedlist"><ul class="itemizedlist" type="disc">
|
||||||
<li>
|
<li class="listitem">
|
||||||
<span class="bold"><strong>Requirements: </strong></span><code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> is initialized.
|
<span class="bold"><strong>Requirements: </strong></span><code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> is initialized.
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li class="listitem">
|
||||||
<span class="bold"><strong>Returns:</strong></span> A pointer to the contained value.
|
<span class="bold"><strong>Returns:</strong></span> A pointer to the contained value.
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li class="listitem">
|
||||||
<span class="bold"><strong>Throws:</strong></span> Nothing.
|
<span class="bold"><strong>Throws:</strong></span> Nothing.
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li class="listitem">
|
||||||
<span class="bold"><strong>Notes:</strong></span> The requirement is asserted via
|
<span class="bold"><strong>Notes:</strong></span> The requirement is asserted via
|
||||||
<code class="computeroutput"><span class="identifier">BOOST_ASSERT</span><span class="special">()</span></code>.
|
<code class="computeroutput"><span class="identifier">BOOST_ASSERT</span><span class="special">()</span></code>.
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li class="listitem">
|
||||||
<span class="bold"><strong>Example:</strong></span><pre class="programlisting"><span class="keyword">struct</span> <span class="identifier">X</span> <span class="special">{</span> <span class="keyword">int</span> <span class="identifier">mdata</span> <span class="special">;</span> <span class="special">}</span> <span class="special">;</span>
|
<span class="bold"><strong>Example:</strong></span><pre class="programlisting"><span class="keyword">struct</span> <span class="identifier">X</span> <span class="special">{</span> <span class="keyword">int</span> <span class="identifier">mdata</span> <span class="special">;</span> <span class="special">}</span> <span class="special">;</span>
|
||||||
<span class="identifier">X</span> <span class="identifier">x</span> <span class="special">;</span>
|
<span class="identifier">X</span> <span class="identifier">x</span> <span class="special">;</span>
|
||||||
<span class="identifier">optional</span><span class="special"><</span><span class="identifier">X</span><span class="special">></span> <span class="identifier">opt</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">X</span><span class="special">></span> <span class="identifier">opt</span> <span class="special">(</span><span class="identifier">x</span><span class="special">);</span>
|
||||||
@ -1230,15 +1230,15 @@
|
|||||||
<p>
|
<p>
|
||||||
</p>
|
</p>
|
||||||
</blockquote></div>
|
</blockquote></div>
|
||||||
<div class="itemizedlist"><ul type="disc">
|
<div class="itemizedlist"><ul class="itemizedlist" type="disc">
|
||||||
<li>
|
<li class="listitem">
|
||||||
<span class="bold"><strong>Returns:</strong></span> An unspecified value which if used
|
<span class="bold"><strong>Returns:</strong></span> An unspecified value which if used
|
||||||
on a boolean context is equivalent to (<code class="computeroutput"><span class="identifier">get</span><span class="special">()</span> <span class="special">!=</span> <span class="number">0</span></code>)
|
on a boolean context is equivalent to (<code class="computeroutput"><span class="identifier">get</span><span class="special">()</span> <span class="special">!=</span> <span class="number">0</span></code>)
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li class="listitem">
|
||||||
<span class="bold"><strong>Throws:</strong></span> Nothing.
|
<span class="bold"><strong>Throws:</strong></span> Nothing.
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li class="listitem">
|
||||||
<span class="bold"><strong>Example:</strong></span><pre class="programlisting"><span class="identifier">optional</span><span class="special"><</span><span class="identifier">T</span><span class="special">></span> <span class="identifier">def</span> <span class="special">;</span>
|
<span class="bold"><strong>Example:</strong></span><pre class="programlisting"><span class="identifier">optional</span><span class="special"><</span><span class="identifier">T</span><span class="special">></span> <span class="identifier">def</span> <span class="special">;</span>
|
||||||
<span class="identifier">assert</span> <span class="special">(</span> <span class="identifier">def</span> <span class="special">==</span> <span class="number">0</span> <span class="special">);</span>
|
<span class="identifier">assert</span> <span class="special">(</span> <span class="identifier">def</span> <span class="special">==</span> <span class="number">0</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="identifier">v</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="identifier">opt</span> <span class="special">(</span> <span class="identifier">v</span> <span class="special">)</span> <span class="special">;</span>
|
||||||
@ -1261,20 +1261,20 @@
|
|||||||
<p>
|
<p>
|
||||||
</p>
|
</p>
|
||||||
</blockquote></div>
|
</blockquote></div>
|
||||||
<div class="itemizedlist"><ul type="disc">
|
<div class="itemizedlist"><ul class="itemizedlist" type="disc">
|
||||||
<li>
|
<li class="listitem">
|
||||||
<span class="bold"><strong>Returns:</strong></span> If <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> is uninitialized, <code class="computeroutput"><span class="keyword">true</span></code>;
|
<span class="bold"><strong>Returns:</strong></span> If <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> is uninitialized, <code class="computeroutput"><span class="keyword">true</span></code>;
|
||||||
else <code class="computeroutput"><span class="keyword">false</span></code>.
|
else <code class="computeroutput"><span class="keyword">false</span></code>.
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li class="listitem">
|
||||||
<span class="bold"><strong>Throws:</strong></span> Nothing.
|
<span class="bold"><strong>Throws:</strong></span> Nothing.
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li class="listitem">
|
||||||
<span class="bold"><strong>Notes:</strong></span> This operator is provided for those
|
<span class="bold"><strong>Notes:</strong></span> This operator is provided for those
|
||||||
compilers which can't use the <span class="emphasis"><em>unspecified-bool-type operator</em></span>
|
compilers which can't use the <span class="emphasis"><em>unspecified-bool-type operator</em></span>
|
||||||
in certain boolean contexts.
|
in certain boolean contexts.
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li class="listitem">
|
||||||
<span class="bold"><strong>Example:</strong></span><pre class="programlisting"><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="bold"><strong>Example:</strong></span><pre class="programlisting"><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="identifier">assert</span> <span class="special">(</span> <span class="special">!</span><span class="identifier">opt</span> <span class="special">);</span>
|
<span class="identifier">assert</span> <span class="special">(</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">some_T</span> <span class="special">;</span>
|
<span class="special">*</span><span class="identifier">opt</span> <span class="special">=</span> <span class="identifier">some_T</span> <span class="special">;</span>
|
||||||
@ -1298,16 +1298,16 @@
|
|||||||
<p>
|
<p>
|
||||||
</p>
|
</p>
|
||||||
</blockquote></div>
|
</blockquote></div>
|
||||||
<div class="itemizedlist"><ul type="disc">
|
<div class="itemizedlist"><ul class="itemizedlist" type="disc">
|
||||||
<li>
|
<li class="listitem">
|
||||||
<span class="bold"><strong>Returns: </strong></span><code class="computeroutput"><span class="keyword">true</span></code>
|
<span class="bold"><strong>Returns: </strong></span><code class="computeroutput"><span class="keyword">true</span></code>
|
||||||
if the <code class="computeroutput"><span class="identifier">optional</span></code> is initialized,
|
if the <code class="computeroutput"><span class="identifier">optional</span></code> is initialized,
|
||||||
<code class="computeroutput"><span class="keyword">false</span></code> otherwise.
|
<code class="computeroutput"><span class="keyword">false</span></code> otherwise.
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li class="listitem">
|
||||||
<span class="bold"><strong>Throws:</strong></span> Nothing.
|
<span class="bold"><strong>Throws:</strong></span> Nothing.
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li class="listitem">
|
||||||
<span class="bold"><strong>Example:</strong></span><pre class="programlisting"><span class="identifier">optional</span><span class="special"><</span><span class="identifier">T</span><span class="special">></span> <span class="identifier">def</span> <span class="special">;</span>
|
<span class="bold"><strong>Example:</strong></span><pre class="programlisting"><span class="identifier">optional</span><span class="special"><</span><span class="identifier">T</span><span class="special">></span> <span class="identifier">def</span> <span class="special">;</span>
|
||||||
<span class="identifier">assert</span> <span class="special">(</span> <span class="special">!</span><span class="identifier">def</span><span class="special">.</span><span class="identifier">is_initialized</span><span class="special">()</span> <span class="special">);</span>
|
<span class="identifier">assert</span> <span class="special">(</span> <span class="special">!</span><span class="identifier">def</span><span class="special">.</span><span class="identifier">is_initialized</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="identifier">opt</span> <span class="special">(</span> <span class="identifier">v</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="identifier">opt</span> <span class="special">(</span> <span class="identifier">v</span> <span class="special">)</span> <span class="special">;</span>
|
||||||
@ -1319,7 +1319,7 @@
|
|||||||
<span class="inlinemediaobject"><img src="../images/space.png" alt="space"></span>
|
<span class="inlinemediaobject"><img src="../images/space.png" alt="space"></span>
|
||||||
</p>
|
</p>
|
||||||
<a name="boost_optional.detailed_semantics.free_functions"></a><h4>
|
<a name="boost_optional.detailed_semantics.free_functions"></a><h4>
|
||||||
<a name="id2853708"></a>
|
<a name="id572503"></a>
|
||||||
<a class="link" href="detailed_semantics.html#boost_optional.detailed_semantics.free_functions">Free functions</a>
|
<a class="link" href="detailed_semantics.html#boost_optional.detailed_semantics.free_functions">Free functions</a>
|
||||||
</h4>
|
</h4>
|
||||||
<p>
|
<p>
|
||||||
@ -1336,13 +1336,13 @@
|
|||||||
<p>
|
<p>
|
||||||
</p>
|
</p>
|
||||||
</blockquote></div>
|
</blockquote></div>
|
||||||
<div class="itemizedlist"><ul type="disc">
|
<div class="itemizedlist"><ul class="itemizedlist" type="disc">
|
||||||
<li>
|
<li class="listitem">
|
||||||
<span class="bold"><strong>Returns: </strong></span><code class="computeroutput"><span class="identifier">optional</span><span class="special"><</span><span class="identifier">T</span><span class="special">>(</span><span class="identifier">v</span><span class="special">)</span></code> for
|
<span class="bold"><strong>Returns: </strong></span><code class="computeroutput"><span class="identifier">optional</span><span class="special"><</span><span class="identifier">T</span><span class="special">>(</span><span class="identifier">v</span><span class="special">)</span></code> for
|
||||||
the <span class="emphasis"><em>deduced</em></span> type <code class="computeroutput"><span class="identifier">T</span></code>
|
the <span class="emphasis"><em>deduced</em></span> type <code class="computeroutput"><span class="identifier">T</span></code>
|
||||||
of <code class="computeroutput"><span class="identifier">v</span></code>.
|
of <code class="computeroutput"><span class="identifier">v</span></code>.
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li class="listitem">
|
||||||
<span class="bold"><strong>Example:</strong></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">void</span> <span class="identifier">foo</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>
|
<span class="bold"><strong>Example:</strong></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">void</span> <span class="identifier">foo</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>
|
||||||
|
|
||||||
<span class="identifier">foo</span> <span class="special">(</span> <span class="identifier">make_optional</span><span class="special">(</span><span class="number">1</span><span class="special">+</span><span class="number">1</span><span class="special">)</span> <span class="special">)</span> <span class="special">;</span> <span class="comment">// Creates an optional<int>
|
<span class="identifier">foo</span> <span class="special">(</span> <span class="identifier">make_optional</span><span class="special">(</span><span class="number">1</span><span class="special">+</span><span class="number">1</span><span class="special">)</span> <span class="special">)</span> <span class="special">;</span> <span class="comment">// Creates an optional<int>
|
||||||
@ -1364,13 +1364,13 @@
|
|||||||
<p>
|
<p>
|
||||||
</p>
|
</p>
|
||||||
</blockquote></div>
|
</blockquote></div>
|
||||||
<div class="itemizedlist"><ul type="disc">
|
<div class="itemizedlist"><ul class="itemizedlist" type="disc">
|
||||||
<li>
|
<li class="listitem">
|
||||||
<span class="bold"><strong>Returns: </strong></span><code class="computeroutput"><span class="identifier">optional</span><span class="special"><</span><span class="identifier">T</span><span class="special">>(</span><span class="identifier">condition</span><span class="special">,</span><span class="identifier">v</span><span class="special">)</span></code> for
|
<span class="bold"><strong>Returns: </strong></span><code class="computeroutput"><span class="identifier">optional</span><span class="special"><</span><span class="identifier">T</span><span class="special">>(</span><span class="identifier">condition</span><span class="special">,</span><span class="identifier">v</span><span class="special">)</span></code> for
|
||||||
the <span class="emphasis"><em>deduced</em></span> type <code class="computeroutput"><span class="identifier">T</span></code>
|
the <span class="emphasis"><em>deduced</em></span> type <code class="computeroutput"><span class="identifier">T</span></code>
|
||||||
of <code class="computeroutput"><span class="identifier">v</span></code>.
|
of <code class="computeroutput"><span class="identifier">v</span></code>.
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li class="listitem">
|
||||||
<span class="bold"><strong>Example:</strong></span><pre class="programlisting"><span class="identifier">optional</span><span class="special"><</span><span class="keyword">double</span><span class="special">></span> <span class="identifier">calculate_foo</span><span class="special">()</span>
|
<span class="bold"><strong>Example:</strong></span><pre class="programlisting"><span class="identifier">optional</span><span class="special"><</span><span class="keyword">double</span><span class="special">></span> <span class="identifier">calculate_foo</span><span class="special">()</span>
|
||||||
<span class="special">{</span>
|
<span class="special">{</span>
|
||||||
<span class="keyword">double</span> <span class="identifier">val</span> <span class="special">=</span> <span class="identifier">compute_foo</span><span class="special">();</span>
|
<span class="keyword">double</span> <span class="identifier">val</span> <span class="special">=</span> <span class="identifier">compute_foo</span><span class="special">();</span>
|
||||||
@ -1398,17 +1398,17 @@
|
|||||||
<p>
|
<p>
|
||||||
</p>
|
</p>
|
||||||
</blockquote></div>
|
</blockquote></div>
|
||||||
<div class="itemizedlist"><ul type="disc">
|
<div class="itemizedlist"><ul class="itemizedlist" type="disc">
|
||||||
<li>
|
<li class="listitem">
|
||||||
<span class="bold"><strong>Returns:</strong></span> If both <code class="computeroutput"><span class="identifier">x</span></code>
|
<span class="bold"><strong>Returns:</strong></span> If both <code class="computeroutput"><span class="identifier">x</span></code>
|
||||||
and <code class="computeroutput"><span class="identifier">y</span></code> are initialized, <code class="computeroutput"><span class="special">(*</span><span class="identifier">x</span> <span class="special">==</span>
|
and <code class="computeroutput"><span class="identifier">y</span></code> are initialized, <code class="computeroutput"><span class="special">(*</span><span class="identifier">x</span> <span class="special">==</span>
|
||||||
<span class="special">*</span><span class="identifier">y</span><span class="special">)</span></code>. If only <code class="computeroutput"><span class="identifier">x</span></code>
|
<span class="special">*</span><span class="identifier">y</span><span class="special">)</span></code>. If only <code class="computeroutput"><span class="identifier">x</span></code>
|
||||||
or <code class="computeroutput"><span class="identifier">y</span></code> is initialized, <code class="computeroutput"><span class="keyword">false</span></code>. If both are uninitialized, <code class="computeroutput"><span class="keyword">true</span></code>.
|
or <code class="computeroutput"><span class="identifier">y</span></code> is initialized, <code class="computeroutput"><span class="keyword">false</span></code>. If both are uninitialized, <code class="computeroutput"><span class="keyword">true</span></code>.
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li class="listitem">
|
||||||
<span class="bold"><strong>Throws:</strong></span> Nothing.
|
<span class="bold"><strong>Throws:</strong></span> Nothing.
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li class="listitem">
|
||||||
<span class="bold"><strong>Notes:</strong></span> Pointers have shallow relational
|
<span class="bold"><strong>Notes:</strong></span> Pointers have shallow relational
|
||||||
operators while <code class="computeroutput"><span class="identifier">optional</span></code>
|
operators while <code class="computeroutput"><span class="identifier">optional</span></code>
|
||||||
has deep relational operators. Do not use <code class="computeroutput"><span class="keyword">operator</span>
|
has deep relational operators. Do not use <code class="computeroutput"><span class="keyword">operator</span>
|
||||||
@ -1417,7 +1417,7 @@
|
|||||||
or a pointer; use <a href="../../../../utility/OptionalPointee.html#equal" target="_top"><code class="computeroutput"><span class="identifier">equal_pointees</span><span class="special">()</span></code></a>
|
or a pointer; use <a href="../../../../utility/OptionalPointee.html#equal" target="_top"><code class="computeroutput"><span class="identifier">equal_pointees</span><span class="special">()</span></code></a>
|
||||||
instead
|
instead
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li class="listitem">
|
||||||
<span class="bold"><strong>Example:</strong></span><pre class="programlisting"><span class="identifier">T</span> <span class="identifier">x</span><span class="special">(</span><span class="number">12</span><span class="special">);</span>
|
<span class="bold"><strong>Example:</strong></span><pre class="programlisting"><span class="identifier">T</span> <span class="identifier">x</span><span class="special">(</span><span class="number">12</span><span class="special">);</span>
|
||||||
<span class="identifier">T</span> <span class="identifier">y</span><span class="special">(</span><span class="number">12</span><span class="special">);</span>
|
<span class="identifier">T</span> <span class="identifier">y</span><span class="special">(</span><span class="number">12</span><span class="special">);</span>
|
||||||
<span class="identifier">T</span> <span class="identifier">z</span><span class="special">(</span><span class="number">21</span><span class="special">);</span>
|
<span class="identifier">T</span> <span class="identifier">z</span><span class="special">(</span><span class="number">21</span><span class="special">);</span>
|
||||||
@ -1459,17 +1459,17 @@
|
|||||||
<p>
|
<p>
|
||||||
</p>
|
</p>
|
||||||
</blockquote></div>
|
</blockquote></div>
|
||||||
<div class="itemizedlist"><ul type="disc">
|
<div class="itemizedlist"><ul class="itemizedlist" type="disc">
|
||||||
<li>
|
<li class="listitem">
|
||||||
<span class="bold"><strong>Returns:</strong></span> If <code class="computeroutput"><span class="identifier">y</span></code>
|
<span class="bold"><strong>Returns:</strong></span> If <code class="computeroutput"><span class="identifier">y</span></code>
|
||||||
is not initialized, <code class="computeroutput"><span class="keyword">false</span></code>. If
|
is not initialized, <code class="computeroutput"><span class="keyword">false</span></code>. If
|
||||||
<code class="computeroutput"><span class="identifier">y</span></code> is initialized and <code class="computeroutput"><span class="identifier">x</span></code> is not initialized, <code class="computeroutput"><span class="keyword">true</span></code>.
|
<code class="computeroutput"><span class="identifier">y</span></code> is initialized and <code class="computeroutput"><span class="identifier">x</span></code> is not initialized, <code class="computeroutput"><span class="keyword">true</span></code>.
|
||||||
If both <code class="computeroutput"><span class="identifier">x</span></code> and <code class="computeroutput"><span class="identifier">y</span></code> are initialized, <code class="computeroutput"><span class="special">(*</span><span class="identifier">x</span> <span class="special"><</span> <span class="special">*</span><span class="identifier">y</span><span class="special">)</span></code>.
|
If both <code class="computeroutput"><span class="identifier">x</span></code> and <code class="computeroutput"><span class="identifier">y</span></code> are initialized, <code class="computeroutput"><span class="special">(*</span><span class="identifier">x</span> <span class="special"><</span> <span class="special">*</span><span class="identifier">y</span><span class="special">)</span></code>.
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li class="listitem">
|
||||||
<span class="bold"><strong>Throws:</strong></span> Nothing.
|
<span class="bold"><strong>Throws:</strong></span> Nothing.
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li class="listitem">
|
||||||
<span class="bold"><strong>Notes:</strong></span> Pointers have shallow relational
|
<span class="bold"><strong>Notes:</strong></span> Pointers have shallow relational
|
||||||
operators while <code class="computeroutput"><span class="identifier">optional</span></code>
|
operators while <code class="computeroutput"><span class="identifier">optional</span></code>
|
||||||
has deep relational operators. Do not use <code class="computeroutput"><span class="keyword">operator</span>
|
has deep relational operators. Do not use <code class="computeroutput"><span class="keyword">operator</span>
|
||||||
@ -1478,7 +1478,7 @@
|
|||||||
or a pointer; use <a href="../../../../utility/OptionalPointee.html#less" target="_top"><code class="computeroutput"><span class="identifier">less_pointees</span><span class="special">()</span></code></a>
|
or a pointer; use <a href="../../../../utility/OptionalPointee.html#less" target="_top"><code class="computeroutput"><span class="identifier">less_pointees</span><span class="special">()</span></code></a>
|
||||||
instead.
|
instead.
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li class="listitem">
|
||||||
<span class="bold"><strong>Example:</strong></span><pre class="programlisting"><span class="identifier">T</span> <span class="identifier">x</span><span class="special">(</span><span class="number">12</span><span class="special">);</span>
|
<span class="bold"><strong>Example:</strong></span><pre class="programlisting"><span class="identifier">T</span> <span class="identifier">x</span><span class="special">(</span><span class="number">12</span><span class="special">);</span>
|
||||||
<span class="identifier">T</span> <span class="identifier">y</span><span class="special">(</span><span class="number">34</span><span class="special">);</span>
|
<span class="identifier">T</span> <span class="identifier">y</span><span class="special">(</span><span class="number">34</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">def</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">def</span> <span class="special">;</span>
|
||||||
@ -1516,13 +1516,13 @@
|
|||||||
<p>
|
<p>
|
||||||
</p>
|
</p>
|
||||||
</blockquote></div>
|
</blockquote></div>
|
||||||
<div class="itemizedlist"><ul type="disc">
|
<div class="itemizedlist"><ul class="itemizedlist" type="disc">
|
||||||
<li>
|
<li class="listitem">
|
||||||
<span class="bold"><strong>Returns: </strong></span><code class="computeroutput"><span class="special">!(</span>
|
<span class="bold"><strong>Returns: </strong></span><code class="computeroutput"><span class="special">!(</span>
|
||||||
<span class="identifier">x</span> <span class="special">==</span>
|
<span class="identifier">x</span> <span class="special">==</span>
|
||||||
<span class="identifier">y</span> <span class="special">);</span></code>
|
<span class="identifier">y</span> <span class="special">);</span></code>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li class="listitem">
|
||||||
<span class="bold"><strong>Throws:</strong></span> Nothing.
|
<span class="bold"><strong>Throws:</strong></span> Nothing.
|
||||||
</li>
|
</li>
|
||||||
</ul></div>
|
</ul></div>
|
||||||
@ -1542,13 +1542,13 @@
|
|||||||
<p>
|
<p>
|
||||||
</p>
|
</p>
|
||||||
</blockquote></div>
|
</blockquote></div>
|
||||||
<div class="itemizedlist"><ul type="disc">
|
<div class="itemizedlist"><ul class="itemizedlist" type="disc">
|
||||||
<li>
|
<li class="listitem">
|
||||||
<span class="bold"><strong>Returns: </strong></span><code class="computeroutput"><span class="special">(</span>
|
<span class="bold"><strong>Returns: </strong></span><code class="computeroutput"><span class="special">(</span>
|
||||||
<span class="identifier">y</span> <span class="special"><</span>
|
<span class="identifier">y</span> <span class="special"><</span>
|
||||||
<span class="identifier">x</span> <span class="special">);</span></code>
|
<span class="identifier">x</span> <span class="special">);</span></code>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li class="listitem">
|
||||||
<span class="bold"><strong>Throws:</strong></span> Nothing.
|
<span class="bold"><strong>Throws:</strong></span> Nothing.
|
||||||
</li>
|
</li>
|
||||||
</ul></div>
|
</ul></div>
|
||||||
@ -1568,12 +1568,12 @@
|
|||||||
<p>
|
<p>
|
||||||
</p>
|
</p>
|
||||||
</blockquote></div>
|
</blockquote></div>
|
||||||
<div class="itemizedlist"><ul type="disc">
|
<div class="itemizedlist"><ul class="itemizedlist" type="disc">
|
||||||
<li>
|
<li class="listitem">
|
||||||
<span class="bold"><strong>Returns: </strong></span><code class="computeroutput"><span class="special">!(</span>
|
<span class="bold"><strong>Returns: </strong></span><code class="computeroutput"><span class="special">!(</span>
|
||||||
<span class="identifier">y</span><span class="special"><</span><span class="identifier">x</span> <span class="special">);</span></code>
|
<span class="identifier">y</span><span class="special"><</span><span class="identifier">x</span> <span class="special">);</span></code>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li class="listitem">
|
||||||
<span class="bold"><strong>Throws:</strong></span> Nothing.
|
<span class="bold"><strong>Throws:</strong></span> Nothing.
|
||||||
</li>
|
</li>
|
||||||
</ul></div>
|
</ul></div>
|
||||||
@ -1593,12 +1593,12 @@
|
|||||||
<p>
|
<p>
|
||||||
</p>
|
</p>
|
||||||
</blockquote></div>
|
</blockquote></div>
|
||||||
<div class="itemizedlist"><ul type="disc">
|
<div class="itemizedlist"><ul class="itemizedlist" type="disc">
|
||||||
<li>
|
<li class="listitem">
|
||||||
<span class="bold"><strong>Returns: </strong></span><code class="computeroutput"><span class="special">!(</span>
|
<span class="bold"><strong>Returns: </strong></span><code class="computeroutput"><span class="special">!(</span>
|
||||||
<span class="identifier">x</span><span class="special"><</span><span class="identifier">y</span> <span class="special">);</span></code>
|
<span class="identifier">x</span><span class="special"><</span><span class="identifier">y</span> <span class="special">);</span></code>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li class="listitem">
|
||||||
<span class="bold"><strong>Throws:</strong></span> Nothing.
|
<span class="bold"><strong>Throws:</strong></span> Nothing.
|
||||||
</li>
|
</li>
|
||||||
</ul></div>
|
</ul></div>
|
||||||
@ -1618,37 +1618,37 @@
|
|||||||
<p>
|
<p>
|
||||||
</p>
|
</p>
|
||||||
</blockquote></div>
|
</blockquote></div>
|
||||||
<div class="itemizedlist"><ul type="disc">
|
<div class="itemizedlist"><ul class="itemizedlist" type="disc">
|
||||||
<li>
|
<li class="listitem">
|
||||||
<span class="bold"><strong>Effect:</strong></span> If both <code class="computeroutput"><span class="identifier">x</span></code>
|
<span class="bold"><strong>Effect:</strong></span> If both <code class="computeroutput"><span class="identifier">x</span></code>
|
||||||
and <code class="computeroutput"><span class="identifier">y</span></code> are initialized, calls
|
and <code class="computeroutput"><span class="identifier">y</span></code> are initialized, calls
|
||||||
<code class="computeroutput"><span class="identifier">swap</span><span class="special">(*</span><span class="identifier">x</span><span class="special">,*</span><span class="identifier">y</span><span class="special">)</span></code> using <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">swap</span></code>.
|
<code class="computeroutput"><span class="identifier">swap</span><span class="special">(*</span><span class="identifier">x</span><span class="special">,*</span><span class="identifier">y</span><span class="special">)</span></code> using <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">swap</span></code>.
|
||||||
If only one is initialized, say <code class="computeroutput"><span class="identifier">x</span></code>,
|
If only one is initialized, say <code class="computeroutput"><span class="identifier">x</span></code>,
|
||||||
calls: <code class="computeroutput"><span class="identifier">y</span><span class="special">.</span><span class="identifier">reset</span><span class="special">(*</span><span class="identifier">x</span><span class="special">);</span> <span class="identifier">x</span><span class="special">.</span><span class="identifier">reset</span><span class="special">();</span></code> If none is initialized, does nothing.
|
calls: <code class="computeroutput"><span class="identifier">y</span><span class="special">.</span><span class="identifier">reset</span><span class="special">(*</span><span class="identifier">x</span><span class="special">);</span> <span class="identifier">x</span><span class="special">.</span><span class="identifier">reset</span><span class="special">();</span></code> If none is initialized, does nothing.
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li class="listitem">
|
||||||
<span class="bold"><strong>Postconditions:</strong></span> The states of <code class="computeroutput"><span class="identifier">x</span></code> and <code class="computeroutput"><span class="identifier">y</span></code>
|
<span class="bold"><strong>Postconditions:</strong></span> The states of <code class="computeroutput"><span class="identifier">x</span></code> and <code class="computeroutput"><span class="identifier">y</span></code>
|
||||||
interchanged.
|
interchanged.
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li class="listitem">
|
||||||
<span class="bold"><strong>Throws:</strong></span> If both are initialized, whatever
|
<span class="bold"><strong>Throws:</strong></span> If both are initialized, whatever
|
||||||
<code class="computeroutput"><span class="identifier">swap</span><span class="special">(</span><span class="identifier">T</span><span class="special">&,</span><span class="identifier">T</span><span class="special">&)</span></code>
|
<code class="computeroutput"><span class="identifier">swap</span><span class="special">(</span><span class="identifier">T</span><span class="special">&,</span><span class="identifier">T</span><span class="special">&)</span></code>
|
||||||
throws. If only one is initialized, whatever <code class="computeroutput"><span class="identifier">T</span><span class="special">::</span><span class="identifier">T</span> <span class="special">(</span>
|
throws. If only one is initialized, whatever <code class="computeroutput"><span class="identifier">T</span><span class="special">::</span><span class="identifier">T</span> <span class="special">(</span>
|
||||||
<span class="identifier">T</span> <span class="keyword">const</span><span class="special">&</span> <span class="special">)</span></code> throws.
|
<span class="identifier">T</span> <span class="keyword">const</span><span class="special">&</span> <span class="special">)</span></code> throws.
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li class="listitem">
|
||||||
<span class="bold"><strong>Notes:</strong></span> If both are initialized, <code class="computeroutput"><span class="identifier">swap</span><span class="special">(</span><span class="identifier">T</span><span class="special">&,</span><span class="identifier">T</span><span class="special">&)</span></code> is used unqualified but with <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">swap</span></code>
|
<span class="bold"><strong>Notes:</strong></span> If both are initialized, <code class="computeroutput"><span class="identifier">swap</span><span class="special">(</span><span class="identifier">T</span><span class="special">&,</span><span class="identifier">T</span><span class="special">&)</span></code> is used unqualified but with <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">swap</span></code>
|
||||||
introduced in scope. If only one is initialized, <code class="computeroutput"><span class="identifier">T</span><span class="special">::~</span><span class="identifier">T</span><span class="special">()</span></code>
|
introduced in scope. If only one is initialized, <code class="computeroutput"><span class="identifier">T</span><span class="special">::~</span><span class="identifier">T</span><span class="special">()</span></code>
|
||||||
and <code class="computeroutput"><span class="identifier">T</span><span class="special">::</span><span class="identifier">T</span><span class="special">(</span> <span class="identifier">T</span>
|
and <code class="computeroutput"><span class="identifier">T</span><span class="special">::</span><span class="identifier">T</span><span class="special">(</span> <span class="identifier">T</span>
|
||||||
<span class="keyword">const</span><span class="special">&</span>
|
<span class="keyword">const</span><span class="special">&</span>
|
||||||
<span class="special">)</span></code> is called.
|
<span class="special">)</span></code> is called.
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li class="listitem">
|
||||||
<span class="bold"><strong>Exception Safety:</strong></span> If both are initialized,
|
<span class="bold"><strong>Exception Safety:</strong></span> If both are initialized,
|
||||||
this operation has the exception safety guarantees of <code class="computeroutput"><span class="identifier">swap</span><span class="special">(</span><span class="identifier">T</span><span class="special">&,</span><span class="identifier">T</span><span class="special">&)</span></code>.
|
this operation has the exception safety guarantees of <code class="computeroutput"><span class="identifier">swap</span><span class="special">(</span><span class="identifier">T</span><span class="special">&,</span><span class="identifier">T</span><span class="special">&)</span></code>.
|
||||||
If only one is initialized, it has the same basic guarantee as <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> <span class="special">)</span></code>.
|
If only one is initialized, it has the same basic guarantee as <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> <span class="special">)</span></code>.
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li class="listitem">
|
||||||
<span class="bold"><strong>Example:</strong></span><pre class="programlisting"><span class="identifier">T</span> <span class="identifier">x</span><span class="special">(</span><span class="number">12</span><span class="special">);</span>
|
<span class="bold"><strong>Example:</strong></span><pre class="programlisting"><span class="identifier">T</span> <span class="identifier">x</span><span class="special">(</span><span class="number">12</span><span class="special">);</span>
|
||||||
<span class="identifier">T</span> <span class="identifier">y</span><span class="special">(</span><span class="number">21</span><span class="special">);</span>
|
<span class="identifier">T</span> <span class="identifier">y</span><span class="special">(</span><span class="number">21</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">def0</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">def0</span> <span class="special">;</span>
|
||||||
|
@ -3,8 +3,8 @@
|
|||||||
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
<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.73.2">
|
<meta name="generator" content="DocBook XSL Stylesheets V1.75.2">
|
||||||
<link rel="start" href="../index.html" title="Chapter<65>1.<2E>Boost.Optional">
|
<link rel="home" href="../index.html" title="Chapter<65>1.<2E>Boost.Optional">
|
||||||
<link rel="up" href="../index.html" title="Chapter<65>1.<2E>Boost.Optional">
|
<link rel="up" href="../index.html" title="Chapter<65>1.<2E>Boost.Optional">
|
||||||
<link rel="prev" href="../index.html" title="Chapter<65>1.<2E>Boost.Optional">
|
<link rel="prev" href="../index.html" title="Chapter<65>1.<2E>Boost.Optional">
|
||||||
<link rel="next" href="synopsis.html" title="Synopsis">
|
<link rel="next" href="synopsis.html" title="Synopsis">
|
||||||
@ -22,7 +22,7 @@
|
|||||||
<div class="spirit-nav">
|
<div class="spirit-nav">
|
||||||
<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>
|
<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" lang="en">
|
<div class="section" title="Development">
|
||||||
<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 class="link" href="development.html" title="Development">Development</a>
|
||||||
</h2></div></div></div>
|
</h2></div></div></div>
|
||||||
@ -31,7 +31,7 @@
|
|||||||
<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" lang="en">
|
<div class="section" title="The models">
|
||||||
<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 class="link" href="development.html#boost_optional.development.the_models" title="The models">The models</a>
|
||||||
</h3></div></div></div>
|
</h3></div></div></div>
|
||||||
@ -110,28 +110,28 @@
|
|||||||
<p>
|
<p>
|
||||||
Discriminated-union:
|
Discriminated-union:
|
||||||
</p>
|
</p>
|
||||||
<div class="itemizedlist"><ul type="disc">
|
<div class="itemizedlist"><ul class="itemizedlist" type="disc">
|
||||||
<li>
|
<li class="listitem">
|
||||||
<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>
|
<li class="listitem">
|
||||||
<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>
|
<li class="listitem">
|
||||||
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>
|
<li class="listitem">
|
||||||
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>
|
<li class="listitem">
|
||||||
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>
|
<li class="listitem">
|
||||||
Trying to extract a <code class="computeroutput"><span class="identifier">T</span></code> from
|
Trying to extract a <code class="computeroutput"><span class="identifier">T</span></code> 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
|
||||||
@ -141,34 +141,34 @@
|
|||||||
<p>
|
<p>
|
||||||
Single-element container:
|
Single-element container:
|
||||||
</p>
|
</p>
|
||||||
<div class="itemizedlist"><ul type="disc">
|
<div class="itemizedlist"><ul class="itemizedlist" type="disc">
|
||||||
<li>
|
<li class="listitem">
|
||||||
<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>
|
<li class="listitem">
|
||||||
<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>
|
<li class="listitem">
|
||||||
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>
|
<li class="listitem">
|
||||||
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>
|
<li class="listitem">
|
||||||
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>
|
<li class="listitem">
|
||||||
Trying to extract a <code class="computeroutput"><span class="identifier">T</span></code> from
|
Trying to extract a <code class="computeroutput"><span class="identifier">T</span></code> from
|
||||||
an empty container models the undefined behavior of trying to access the
|
an empty container models the undefined behavior of trying to access the
|
||||||
value of an uninitialized optional
|
value of an uninitialized optional
|
||||||
</li>
|
</li>
|
||||||
</ul></div>
|
</ul></div>
|
||||||
</div>
|
</div>
|
||||||
<div class="section" lang="en">
|
<div class="section" title="The semantics">
|
||||||
<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 class="link" href="development.html#boost_optional.development.the_semantics" title="The semantics">The semantics</a>
|
||||||
</h3></div></div></div>
|
</h3></div></div></div>
|
||||||
@ -193,55 +193,55 @@
|
|||||||
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 type="disc">
|
<div class="itemizedlist"><ul class="itemizedlist" type="disc">
|
||||||
<li>
|
<li class="listitem">
|
||||||
<span class="bold"><strong>Default Construction:</strong></span> To introduce a formally
|
<span class="bold"><strong>Default Construction:</strong></span> To introduce a formally
|
||||||
uninitialized wrapped object.
|
uninitialized wrapped object.
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li class="listitem">
|
||||||
<span class="bold"><strong>Direct Value Construction via copy:</strong></span> To
|
<span class="bold"><strong>Direct Value Construction via copy:</strong></span> 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>
|
<li class="listitem">
|
||||||
<span class="bold"><strong>Deep Copy Construction:</strong></span> To obtain a new
|
<span class="bold"><strong>Deep Copy Construction:</strong></span> To obtain a new
|
||||||
yet equivalent wrapped object.
|
yet equivalent wrapped object.
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li class="listitem">
|
||||||
<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>
|
<li class="listitem">
|
||||||
<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>
|
<li class="listitem">
|
||||||
<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>
|
<li class="listitem">
|
||||||
<span class="bold"><strong>Assignment (upon uninitialized):</strong></span> To initialize
|
<span class="bold"><strong>Assignment (upon uninitialized):</strong></span> To initialize
|
||||||
the wrapped object with value of another wrapped object.
|
the wrapped object with value of another wrapped object.
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li class="listitem">
|
||||||
<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>
|
<li class="listitem">
|
||||||
<span class="bold"><strong>Value access:</strong></span> To unwrap the wrapped object.
|
<span class="bold"><strong>Value access:</strong></span> To unwrap the wrapped 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>
|
||||||
@ -252,7 +252,7 @@
|
|||||||
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" lang="en">
|
<div class="section" title="The Interface">
|
||||||
<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 class="link" href="development.html#boost_optional.development.the_interface" title="The Interface">The Interface</a>
|
||||||
</h3></div></div></div>
|
</h3></div></div></div>
|
||||||
@ -292,7 +292,7 @@
|
|||||||
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="id2836653"></a>
|
<a name="id555569"></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 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
|
||||||
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>
|
||||||
@ -357,7 +357,7 @@
|
|||||||
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="id2836963"></a>
|
<a name="id555831"></a>
|
||||||
<a class="link" href="development.html#boost_optional.development.the_interface.optional_lt_t_gt__as_a_model_of_optionalpointee">Optional<T>
|
<a class="link" 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>
|
||||||
@ -367,7 +367,7 @@
|
|||||||
about the possibly uninitialized state appealing to the familiar pointer
|
about the possibly uninitialized state appealing to the familiar pointer
|
||||||
semantics w.r.t. to null pointers.
|
semantics w.r.t. to null pointers.
|
||||||
</p>
|
</p>
|
||||||
<div class="warning"><table border="0" summary="Warning">
|
<div class="warning" title="Warning"><table border="0" summary="Warning">
|
||||||
<tr>
|
<tr>
|
||||||
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Warning]" src="../../../../../doc/html/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>
|
||||||
|
@ -3,8 +3,8 @@
|
|||||||
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
<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.73.2">
|
<meta name="generator" content="DocBook XSL Stylesheets V1.75.2">
|
||||||
<link rel="start" href="../index.html" title="Chapter<65>1.<2E>Boost.Optional">
|
<link rel="home" href="../index.html" title="Chapter<65>1.<2E>Boost.Optional">
|
||||||
<link rel="up" href="../index.html" title="Chapter<65>1.<2E>Boost.Optional">
|
<link rel="up" href="../index.html" title="Chapter<65>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">
|
||||||
@ -22,7 +22,7 @@
|
|||||||
<div class="spirit-nav">
|
<div class="spirit-nav">
|
||||||
<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>
|
<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" lang="en">
|
<div class="section" title="Examples">
|
||||||
<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 class="link" href="examples.html" title="Examples">Examples</a>
|
||||||
</h2></div></div></div>
|
</h2></div></div></div>
|
||||||
@ -36,7 +36,7 @@
|
|||||||
<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" lang="en">
|
<div class="section" title="Optional return values">
|
||||||
<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 class="link" href="examples.html#boost_optional.examples.optional_return_values" title="Optional return values">Optional
|
||||||
return values</a>
|
return values</a>
|
||||||
@ -57,7 +57,7 @@
|
|||||||
<span class="special">}</span>
|
<span class="special">}</span>
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
</div>
|
||||||
<div class="section" lang="en">
|
<div class="section" title="Optional local variables">
|
||||||
<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 class="link" href="examples.html#boost_optional.examples.optional_local_variables" title="Optional local variables">Optional
|
||||||
local variables</a>
|
local variables</a>
|
||||||
@ -78,7 +78,7 @@
|
|||||||
<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" lang="en">
|
<div class="section" title="Optional data members">
|
||||||
<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 class="link" href="examples.html#boost_optional.examples.optional_data_members" title="Optional data members">Optional
|
||||||
data members</a>
|
data members</a>
|
||||||
@ -116,7 +116,7 @@
|
|||||||
<span class="special">};</span>
|
<span class="special">};</span>
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
</div>
|
||||||
<div class="section" lang="en">
|
<div class="section" title="Bypassing expensive unnecessary default construction">
|
||||||
<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 class="link" 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>
|
||||||
|
@ -3,8 +3,8 @@
|
|||||||
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
<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.73.2">
|
<meta name="generator" content="DocBook XSL Stylesheets V1.75.2">
|
||||||
<link rel="start" href="../index.html" title="Chapter<65>1.<2E>Boost.Optional">
|
<link rel="home" href="../index.html" title="Chapter<65>1.<2E>Boost.Optional">
|
||||||
<link rel="up" href="../index.html" title="Chapter<65>1.<2E>Boost.Optional">
|
<link rel="up" href="../index.html" title="Chapter<65>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">
|
||||||
@ -22,30 +22,30 @@
|
|||||||
<div class="spirit-nav">
|
<div class="spirit-nav">
|
||||||
<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>
|
<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" lang="en">
|
<div class="section" title="Exception Safety Guarantees">
|
||||||
<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 class="link" 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="../index.html#optional_implementation_notes">Implementation
|
Because of the current implementation (see <a class="link" href="implementation_notes.html" title="Implementation Notes">Implementation
|
||||||
Notes</a>), all of the assignment methods:
|
Notes</a>), all of the assignment methods:
|
||||||
</p>
|
</p>
|
||||||
<div class="itemizedlist"><ul type="disc">
|
<div class="itemizedlist"><ul class="itemizedlist" type="disc">
|
||||||
<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>
|
<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="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="keyword">const</span><span class="special">&</span>
|
||||||
<span class="special">)</span></code></li>
|
<span class="special">)</span></code></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="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>
|
<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="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>
|
||||||
<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 class="listitem"><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="keyword">const</span><span class="special">&</span>
|
||||||
<span class="special">)</span></code></li>
|
<span class="special">)</span></code></li>
|
||||||
<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 class="listitem"><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>
|
||||||
<span class="keyword">const</span><span class="special">&</span>
|
<span class="keyword">const</span><span class="special">&</span>
|
||||||
<span class="special">)</span></code></li>
|
<span class="special">)</span></code></li>
|
||||||
<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>
|
<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="keyword">const</span><span class="special">&</span>
|
||||||
<span class="special">)</span> </code></li>
|
<span class="special">)</span> </code></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="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
|
||||||
@ -56,9 +56,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 type="disc">
|
<div class="itemizedlist"><ul class="itemizedlist" type="disc">
|
||||||
<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>
|
<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="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>
|
||||||
<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 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>)
|
||||||
@ -112,7 +112,7 @@
|
|||||||
<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="id2864737"></a>
|
<a name="id583497"></a>
|
||||||
<a class="link" href="exception_safety_guarantees.html#boost_optional.exception_safety_guarantees.swap">Swap</a>
|
<a class="link" href="exception_safety_guarantees.html#boost_optional.exception_safety_guarantees.swap">Swap</a>
|
||||||
</h4>
|
</h4>
|
||||||
<p>
|
<p>
|
||||||
|
@ -3,8 +3,8 @@
|
|||||||
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
<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.73.2">
|
<meta name="generator" content="DocBook XSL Stylesheets V1.75.2">
|
||||||
<link rel="start" href="../index.html" title="Chapter<65>1.<2E>Boost.Optional">
|
<link rel="home" href="../index.html" title="Chapter<65>1.<2E>Boost.Optional">
|
||||||
<link rel="up" href="../index.html" title="Chapter<65>1.<2E>Boost.Optional">
|
<link rel="up" href="../index.html" title="Chapter<65>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">
|
||||||
@ -22,7 +22,7 @@
|
|||||||
<div class="spirit-nav">
|
<div class="spirit-nav">
|
||||||
<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>
|
<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" lang="en">
|
<div class="section" title="Implementation Notes">
|
||||||
<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 class="link" href="implementation_notes.html" title="Implementation Notes">Implementation Notes</a>
|
||||||
</h2></div></div></div>
|
</h2></div></div></div>
|
||||||
|
@ -3,8 +3,8 @@
|
|||||||
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
<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.73.2">
|
<meta name="generator" content="DocBook XSL Stylesheets V1.75.2">
|
||||||
<link rel="start" href="../index.html" title="Chapter<65>1.<2E>Boost.Optional">
|
<link rel="home" href="../index.html" title="Chapter<65>1.<2E>Boost.Optional">
|
||||||
<link rel="up" href="../index.html" title="Chapter<65>1.<2E>Boost.Optional">
|
<link rel="up" href="../index.html" title="Chapter<65>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 semantics for assignment of optional references">
|
||||||
<link rel="next" href="a_note_about_optional_bool_.html" title="A note about optional<bool>">
|
<link rel="next" href="a_note_about_optional_bool_.html" title="A note about optional<bool>">
|
||||||
@ -22,7 +22,7 @@
|
|||||||
<div class="spirit-nav">
|
<div class="spirit-nav">
|
||||||
<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>
|
<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" lang="en">
|
<div class="section" title="In-Place Factories">
|
||||||
<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 class="link" href="in_place_factories.html" title="In-Place Factories">In-Place Factories</a>
|
||||||
</h2></div></div></div>
|
</h2></div></div></div>
|
||||||
@ -121,18 +121,18 @@
|
|||||||
<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="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> <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 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 type="disc">
|
<div class="itemizedlist"><ul class="itemizedlist" type="disc">
|
||||||
<li>
|
<li class="listitem">
|
||||||
<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>
|
<li class="listitem">
|
||||||
<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.
|
||||||
|
@ -3,8 +3,8 @@
|
|||||||
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
<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.73.2">
|
<meta name="generator" content="DocBook XSL Stylesheets V1.75.2">
|
||||||
<link rel="start" href="../index.html" title="Chapter<65>1.<2E>Boost.Optional">
|
<link rel="home" href="../index.html" title="Chapter<65>1.<2E>Boost.Optional">
|
||||||
<link rel="up" href="../index.html" title="Chapter<65>1.<2E>Boost.Optional">
|
<link rel="up" href="../index.html" title="Chapter<65>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">
|
||||||
@ -22,7 +22,7 @@
|
|||||||
<div class="spirit-nav">
|
<div class="spirit-nav">
|
||||||
<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>
|
<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" lang="en">
|
<div class="section" title="Optional references">
|
||||||
<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 class="link" href="optional_references.html" title="Optional references">Optional references</a>
|
||||||
</h2></div></div></div>
|
</h2></div></div></div>
|
||||||
@ -35,20 +35,20 @@
|
|||||||
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 type="disc">
|
<div class="itemizedlist"><ul class="itemizedlist" type="disc">
|
||||||
<li>
|
<li class="listitem">
|
||||||
Converting constructors
|
Converting constructors
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li class="listitem">
|
||||||
Converting assignment
|
Converting assignment
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li class="listitem">
|
||||||
InPlace construction
|
InPlace construction
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li class="listitem">
|
||||||
InPlace assignment
|
InPlace assignment
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li class="listitem">
|
||||||
Value-access via pointer
|
Value-access via pointer
|
||||||
</li>
|
</li>
|
||||||
</ul></div>
|
</ul></div>
|
||||||
@ -57,13 +57,13 @@
|
|||||||
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 type="disc">
|
<div class="itemizedlist"><ul class="itemizedlist" type="disc">
|
||||||
<li>
|
<li class="listitem">
|
||||||
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>
|
<li class="listitem">
|
||||||
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>
|
||||||
|
@ -3,8 +3,8 @@
|
|||||||
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
<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.73.2">
|
<meta name="generator" content="DocBook XSL Stylesheets V1.75.2">
|
||||||
<link rel="start" href="../index.html" title="Chapter<65>1.<2E>Boost.Optional">
|
<link rel="home" href="../index.html" title="Chapter<65>1.<2E>Boost.Optional">
|
||||||
<link rel="up" href="../index.html" title="Chapter<65>1.<2E>Boost.Optional">
|
<link rel="up" href="../index.html" title="Chapter<65>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">
|
||||||
@ -22,7 +22,7 @@
|
|||||||
<div class="spirit-nav">
|
<div class="spirit-nav">
|
||||||
<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>
|
<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" lang="en">
|
<div class="section" title="Rebinding semantics for assignment of optional references">
|
||||||
<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 class="link" 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>
|
||||||
@ -70,7 +70,7 @@
|
|||||||
<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="id2860344"></a>
|
<a name="id579234"></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 class="link" 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>
|
||||||
|
@ -3,8 +3,8 @@
|
|||||||
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
<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.73.2">
|
<meta name="generator" content="DocBook XSL Stylesheets V1.75.2">
|
||||||
<link rel="start" href="../index.html" title="Chapter<65>1.<2E>Boost.Optional">
|
<link rel="home" href="../index.html" title="Chapter<65>1.<2E>Boost.Optional">
|
||||||
<link rel="up" href="../index.html" title="Chapter<65>1.<2E>Boost.Optional">
|
<link rel="up" href="../index.html" title="Chapter<65>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">
|
||||||
@ -22,7 +22,7 @@
|
|||||||
<div class="spirit-nav">
|
<div class="spirit-nav">
|
||||||
<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>
|
<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" lang="en">
|
<div class="section" title="Synopsis">
|
||||||
<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 class="link" href="synopsis.html" title="Synopsis">Synopsis</a>
|
||||||
</h2></div></div></div>
|
</h2></div></div></div>
|
||||||
|
@ -3,8 +3,8 @@
|
|||||||
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
<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.73.2">
|
<meta name="generator" content="DocBook XSL Stylesheets V1.75.2">
|
||||||
<link rel="start" href="../index.html" title="Chapter<65>1.<2E>Boost.Optional">
|
<link rel="home" href="../index.html" title="Chapter<65>1.<2E>Boost.Optional">
|
||||||
<link rel="up" href="../index.html" title="Chapter<65>1.<2E>Boost.Optional">
|
<link rel="up" href="../index.html" title="Chapter<65>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">
|
||||||
@ -22,7 +22,7 @@
|
|||||||
<div class="spirit-nav">
|
<div class="spirit-nav">
|
||||||
<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>
|
<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" lang="en">
|
<div class="section" title="Type requirements">
|
||||||
<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 class="link" href="type_requirements.html" title="Type requirements">Type requirements</a>
|
||||||
</h2></div></div></div>
|
</h2></div></div></div>
|
||||||
|
Before Width: | Height: | Size: 391 B |
Before Width: | Height: | Size: 485 B |
Before Width: | Height: | Size: 410 B |
Before Width: | Height: | Size: 488 B |
Before Width: | Height: | Size: 509 B |
Before Width: | Height: | Size: 499 B |
Before Width: | Height: | Size: 507 B |
Before Width: | Height: | Size: 446 B |
Before Width: | Height: | Size: 431 B |
Before Width: | Height: | Size: 441 B |
Before Width: | Height: | Size: 423 B |
Before Width: | Height: | Size: 431 B |
Before Width: | Height: | Size: 397 B |
Before Width: | Height: | Size: 434 B |
Before Width: | Height: | Size: 420 B |
Before Width: | Height: | Size: 4.2 KiB |
Before Width: | Height: | Size: 1.1 KiB |
Before Width: | Height: | Size: 4.6 KiB |
Before Width: | Height: | Size: 768 B |
Before Width: | Height: | Size: 4.5 KiB |
Before Width: | Height: | Size: 741 B |
Before Width: | Height: | Size: 3.8 KiB |
Before Width: | Height: | Size: 766 B |
Before Width: | Height: | Size: 3.8 KiB |
@ -3,8 +3,8 @@
|
|||||||
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
||||||
<title>Chapter<EFBFBD>1.<2E>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.73.2">
|
<meta name="generator" content="DocBook XSL Stylesheets V1.75.2">
|
||||||
<link rel="start" href="index.html" title="Chapter<65>1.<2E>Boost.Optional">
|
<link rel="home" href="index.html" title="Chapter<65>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">
|
||||||
@ -18,7 +18,7 @@
|
|||||||
</tr></table>
|
</tr></table>
|
||||||
<hr>
|
<hr>
|
||||||
<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="spirit-nav"><a accesskey="n" href="boost_optional/development.html"><img src="../../../../doc/html/images/next.png" alt="Next"></a></div>
|
||||||
<div class="chapter" lang="en">
|
<div class="chapter" title="Chapter<EFBFBD>1.<2E>Boost.Optional">
|
||||||
<div class="titlepage"><div>
|
<div class="titlepage"><div>
|
||||||
<div><h2 class="title">
|
<div><h2 class="title">
|
||||||
<a name="optional"></a>Chapter<EFBFBD>1.<2E>Boost.Optional</h2></div>
|
<a name="optional"></a>Chapter<EFBFBD>1.<2E>Boost.Optional</h2></div>
|
||||||
@ -26,8 +26,8 @@
|
|||||||
<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 <20> 2003 -2007 Fernando Luis Cacciola Carballal</p></div>
|
<div><p class="copyright">Copyright <20> 2003 -2007 Fernando Luis Cacciola Carballal</p></div>
|
||||||
<div><div class="legalnotice">
|
<div><div class="legalnotice" title="Legal Notice">
|
||||||
<a name="id2826039"></a><p>
|
<a name="id553943"></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,7 +71,7 @@
|
|||||||
<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" lang="en">
|
<div class="section" title="Motivation">
|
||||||
<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 class="link" href="index.html#optional.motivation" title="Motivation">Motivation</a>
|
||||||
</h2></div></div></div>
|
</h2></div></div></div>
|
||||||
@ -79,15 +79,15 @@
|
|||||||
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 type="disc">
|
<div class="itemizedlist"><ul class="itemizedlist" type="disc">
|
||||||
<li>
|
<li class="listitem">
|
||||||
(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>
|
(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>
|
<span class="special">);</span></code>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li class="listitem">
|
||||||
(B) <code class="computeroutput"><span class="keyword">char</span> <span class="identifier">get_async_input</span><span class="special">();</span></code>
|
(B) <code class="computeroutput"><span class="keyword">char</span> <span class="identifier">get_async_input</span><span class="special">();</span></code>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li class="listitem">
|
||||||
(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>
|
(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>
|
||||||
</ul></div>
|
</ul></div>
|
||||||
@ -164,15 +164,9 @@
|
|||||||
</div>
|
</div>
|
||||||
<p>
|
<p>
|
||||||
</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: October 10, 2008 at 20:53:37 GMT</small></p></td>
|
<td align="left"><p><small>Last revised: November 20, 2009 at 10:24:28 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>
|
||||||
|
@ -10,8 +10,6 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
[#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
|
||||||
|
1676
doc/optional.html
@ -331,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 optional_in_place_factories In-Place Factories]
|
* [*Notes:] See [link boost_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.
|
||||||
@ -385,7 +385,7 @@ __SPACE__
|
|||||||
* [*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 optional_refassign here] for details on this behavior.
|
See [link boost_optional.rebinding_semantics_for_assignment_of_optional_references here] for details on this behavior.
|
||||||
* [*Example:]
|
* [*Example:]
|
||||||
``
|
``
|
||||||
int a = 1 ;
|
int a = 1 ;
|
||||||
@ -444,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 optional_refassign here] for details on this behavior.
|
the new object. See [link boost_optional.rebinding_semantics_for_assignment_of_optional_references here] for details on this behavior.
|
||||||
* [*Example:]
|
* [*Example:]
|
||||||
``
|
``
|
||||||
int a = 1 ;
|
int a = 1 ;
|
||||||
|
@ -23,8 +23,6 @@ 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
|
||||||
@ -112,8 +110,6 @@ In such scenario, you can assign the value itself directly, as in:
|
|||||||
|
|
||||||
[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
|
||||||
@ -205,7 +201,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&rt(123,"hello")) ;
|
W ( TypedInPlaceFactory2<X,int,std::string>(123,"hello")) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
The factories are divided in two groups:
|
The factories are divided in two groups:
|
||||||
@ -288,7 +284,7 @@ instead, it won't compile).
|
|||||||
|
|
||||||
[section Exception Safety Guarantees]
|
[section Exception Safety Guarantees]
|
||||||
|
|
||||||
Because of the current implementation (see [link optional_implementation_notes Implementation Notes]), all of the assignment methods:
|
Because of the current implementation (see [link boost_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& )`
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
|
|
||||||
namespace boost {
|
namespace boost {
|
||||||
|
|
||||||
none_t const none = ((none_t)0) ;
|
none_t const none = (static_cast<none_t>(0)) ;
|
||||||
|
|
||||||
} // namespace boost
|
} // namespace boost
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// Copyright (C) 2003, Fernando Luis Cacciola Carballal.
|
// Copyright (C) 2003, 2008 Fernando Luis Cacciola Carballal.
|
||||||
//
|
//
|
||||||
// Use, modification, and distribution is subject to the Boost Software
|
// Use, modification, and distribution is subject to the Boost Software
|
||||||
// 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
|
||||||
@ -9,6 +9,9 @@
|
|||||||
// 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:
|
||||||
|
// 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
|
||||||
|
|
||||||
@ -19,6 +22,7 @@
|
|||||||
#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/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"
|
||||||
@ -28,6 +32,7 @@
|
|||||||
#include "boost/detail/reference_content.hpp"
|
#include "boost/detail/reference_content.hpp"
|
||||||
#include "boost/none.hpp"
|
#include "boost/none.hpp"
|
||||||
#include "boost/utility/compare_pointees.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"
|
||||||
|
|
||||||
@ -168,8 +173,10 @@ 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 ;
|
||||||
@ -516,7 +523,7 @@ class optional : public optional_detail::optional_base<T>
|
|||||||
|
|
||||||
// Creates a deep copy of another optional<T>
|
// Creates a deep copy of another optional<T>
|
||||||
// Can throw if T::T(T const&) does
|
// Can throw if T::T(T const&) does
|
||||||
optional ( optional const& rhs ) : base(rhs) {}
|
optional ( optional const& rhs ) : base( static_cast<base const&>(rhs) ) {}
|
||||||
|
|
||||||
// No-throw (assuming T::~T() doesn't)
|
// No-throw (assuming T::~T() doesn't)
|
||||||
~optional() {}
|
~optional() {}
|
||||||
@ -550,7 +557,7 @@ class optional : public optional_detail::optional_base<T>
|
|||||||
// (NOTE: On BCB, this operator is not actually called and left is left UNMODIFIED in case of a throw)
|
// (NOTE: On BCB, this operator is not actually called and left is left UNMODIFIED in case of a throw)
|
||||||
optional& operator= ( optional const& rhs )
|
optional& operator= ( optional const& rhs )
|
||||||
{
|
{
|
||||||
this->assign( rhs ) ;
|
this->assign( static_cast<base const&>(rhs) ) ;
|
||||||
return *this ;
|
return *this ;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -571,6 +578,14 @@ class optional : public optional_detail::optional_base<T>
|
|||||||
return *this ;
|
return *this ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void swap( optional & arg )
|
||||||
|
{
|
||||||
|
// allow for Koenig lookup
|
||||||
|
using boost::swap ;
|
||||||
|
swap(*this, arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Returns a reference to the value if this is initialized, otherwise,
|
// Returns a reference to the value if this is initialized, otherwise,
|
||||||
// the behaviour is UNDEFINED
|
// the behaviour is UNDEFINED
|
||||||
// No-throw
|
// No-throw
|
||||||
@ -878,24 +893,54 @@ namespace optional_detail {
|
|||||||
#define BOOST_OPTIONAL_STD_SWAP_INTRODUCED_AT_NS_SCOPE
|
#define BOOST_OPTIONAL_STD_SWAP_INTRODUCED_AT_NS_SCOPE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// optional's swap:
|
template<bool use_default_constructor> struct swap_selector;
|
||||||
// If both are initialized, calls swap(T&, T&). If this swap throws, both will remain initialized but their values are now unspecified.
|
|
||||||
// If only one is initialized, calls U.reset(*I), THEN I.reset().
|
template<>
|
||||||
// If U.reset(*I) throws, both are left UNCHANGED (U is kept uinitialized and I is never reset)
|
struct swap_selector<true>
|
||||||
// If both are uninitialized, do nothing (no-throw)
|
{
|
||||||
template<class T>
|
template<class T>
|
||||||
inline
|
static void optional_swap ( optional<T>& x, optional<T>& y )
|
||||||
void optional_swap ( optional<T>& x, optional<T>& y )
|
{
|
||||||
|
bool hasX = x;
|
||||||
|
bool hasY = y;
|
||||||
|
|
||||||
|
if ( !hasX && !hasY )
|
||||||
|
return;
|
||||||
|
|
||||||
|
if( !hasX )
|
||||||
|
x = boost::in_place();
|
||||||
|
else if ( !hasY )
|
||||||
|
y = boost::in_place();
|
||||||
|
|
||||||
|
// GCC > 3.2 and all other compilers have the using declaration at function scope (FLC)
|
||||||
|
#ifndef BOOST_OPTIONAL_STD_SWAP_INTRODUCED_AT_NS_SCOPE
|
||||||
|
// allow for Koenig lookup
|
||||||
|
using std::swap ;
|
||||||
|
#endif
|
||||||
|
swap(*x,*y);
|
||||||
|
|
||||||
|
if( !hasX )
|
||||||
|
y = boost::none ;
|
||||||
|
else if( !hasY )
|
||||||
|
x = boost::none ;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template<>
|
||||||
|
struct swap_selector<false>
|
||||||
|
{
|
||||||
|
template<class T>
|
||||||
|
static void optional_swap ( optional<T>& x, optional<T>& y )
|
||||||
{
|
{
|
||||||
if ( !x && !!y )
|
if ( !x && !!y )
|
||||||
{
|
{
|
||||||
x.reset(*y);
|
x = *y;
|
||||||
y.reset();
|
y = boost::none ;
|
||||||
}
|
}
|
||||||
else if ( !!x && !y )
|
else if ( !!x && !y )
|
||||||
{
|
{
|
||||||
y.reset(*x);
|
y = *x ;
|
||||||
x.reset();
|
x = boost::none ;
|
||||||
}
|
}
|
||||||
else if ( !!x && !!y )
|
else if ( !!x && !!y )
|
||||||
{
|
{
|
||||||
@ -907,15 +952,18 @@ void optional_swap ( optional<T>& x, optional<T>& y )
|
|||||||
swap(*x,*y);
|
swap(*x,*y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
} // namespace optional_detail
|
} // namespace optional_detail
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
struct optional_swap_should_use_default_constructor : has_nothrow_default_constructor<T> {} ;
|
||||||
|
|
||||||
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::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
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// Copyright (C) 2003, Fernando Luis Cacciola Carballal.
|
// Copyright (C) 2003, 2008 Fernando Luis Cacciola Carballal.
|
||||||
//
|
//
|
||||||
// Use, modification, and distribution is subject to the Boost Software
|
// Use, modification, and distribution is subject to the Boost Software
|
||||||
// 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
|
||||||
@ -9,6 +9,9 @@
|
|||||||
// 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:
|
||||||
|
// 10 May 2008 (added swap related forward declaration) Niels Dekker
|
||||||
|
//
|
||||||
#ifndef BOOST_OPTIONAL_OPTIONAL_FWD_FLC_19NOV2002_HPP
|
#ifndef BOOST_OPTIONAL_OPTIONAL_FWD_FLC_19NOV2002_HPP
|
||||||
#define BOOST_OPTIONAL_OPTIONAL_FWD_FLC_19NOV2002_HPP
|
#define BOOST_OPTIONAL_OPTIONAL_FWD_FLC_19NOV2002_HPP
|
||||||
|
|
||||||
@ -16,6 +19,10 @@ namespace boost {
|
|||||||
|
|
||||||
template<class T> class optional ;
|
template<class T> class optional ;
|
||||||
|
|
||||||
|
template<class T> void swap ( optional<T>& , optional<T>& ) ;
|
||||||
|
|
||||||
|
template<class T> struct optional_swap_should_use_default_constructor ;
|
||||||
|
|
||||||
} // namespace boost
|
} // namespace boost
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -1 +0,0 @@
|
|||||||
bin
|
|
@ -1,4 +1,4 @@
|
|||||||
// Copyright (C) 2003, Fernando Luis Cacciola Carballal.
|
// Copyright (C) 2003, 2008 Fernando Luis Cacciola Carballal.
|
||||||
//
|
//
|
||||||
// Use, modification, and distribution is subject to the Boost Software
|
// Use, modification, and distribution is subject to the Boost Software
|
||||||
// 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
|
||||||
@ -9,6 +9,9 @@
|
|||||||
// 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:
|
||||||
|
// 12 May 2008 (added more swap tests)
|
||||||
|
//
|
||||||
#include<iostream>
|
#include<iostream>
|
||||||
#include<stdexcept>
|
#include<stdexcept>
|
||||||
#include<string>
|
#include<string>
|
||||||
@ -16,6 +19,8 @@
|
|||||||
#define BOOST_ENABLE_ASSERT_HANDLER
|
#define BOOST_ENABLE_ASSERT_HANDLER
|
||||||
|
|
||||||
#include "boost/bind/apply.hpp" // Included just to test proper interaction with boost::apply<> as reported by Daniel Wallin
|
#include "boost/bind/apply.hpp" // Included just to test proper interaction with boost::apply<> as reported by Daniel Wallin
|
||||||
|
#include "boost/mpl/bool.hpp"
|
||||||
|
#include "boost/mpl/bool_fwd.hpp" // For mpl::true_ and mpl::false_
|
||||||
|
|
||||||
#include "boost/optional/optional.hpp"
|
#include "boost/optional/optional.hpp"
|
||||||
|
|
||||||
@ -927,6 +932,337 @@ void test_conversions2()
|
|||||||
BOOST_CHECK(*get(&opt1) == static_cast<double>(f));
|
BOOST_CHECK(*get(&opt1) == static_cast<double>(f));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
namespace optional_swap_test
|
||||||
|
{
|
||||||
|
class default_ctor_exception : public std::exception {} ;
|
||||||
|
class copy_ctor_exception : public std::exception {} ;
|
||||||
|
class assignment_exception : public std::exception {} ;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Base class for swap test classes. Its assignment should not be called, when swapping
|
||||||
|
// optional<T> objects. (The default std::swap would do so.)
|
||||||
|
//
|
||||||
|
class base_class_with_forbidden_assignment
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
base_class_with_forbidden_assignment & operator=(const base_class_with_forbidden_assignment &)
|
||||||
|
{
|
||||||
|
BOOST_CHECK(!"The assignment should not be used while swapping!");
|
||||||
|
throw assignment_exception();
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual ~base_class_with_forbidden_assignment() {}
|
||||||
|
};
|
||||||
|
|
||||||
|
//
|
||||||
|
// Class without default constructor
|
||||||
|
//
|
||||||
|
class class_without_default_ctor : public base_class_with_forbidden_assignment
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
char data;
|
||||||
|
explicit class_without_default_ctor(char arg) : data(arg) {}
|
||||||
|
};
|
||||||
|
|
||||||
|
//
|
||||||
|
// Class whose default constructor should not be used by optional::swap!
|
||||||
|
//
|
||||||
|
class class_whose_default_ctor_should_not_be_used : public base_class_with_forbidden_assignment
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
char data;
|
||||||
|
explicit class_whose_default_ctor_should_not_be_used(char arg) : data(arg) {}
|
||||||
|
|
||||||
|
class_whose_default_ctor_should_not_be_used()
|
||||||
|
{
|
||||||
|
BOOST_CHECK(!"This default constructor should not be used while swapping!");
|
||||||
|
throw default_ctor_exception();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
//
|
||||||
|
// Class whose default constructor should be used by optional::swap.
|
||||||
|
// Its copy constructor should be avoided!
|
||||||
|
//
|
||||||
|
class class_whose_default_ctor_should_be_used : public base_class_with_forbidden_assignment
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
char data;
|
||||||
|
explicit class_whose_default_ctor_should_be_used(char arg) : data(arg) { }
|
||||||
|
|
||||||
|
class_whose_default_ctor_should_be_used() : data('\0') { }
|
||||||
|
|
||||||
|
class_whose_default_ctor_should_be_used(const class_whose_default_ctor_should_be_used &)
|
||||||
|
{
|
||||||
|
BOOST_CHECK(!"This copy constructor should not be used while swapping!");
|
||||||
|
throw copy_ctor_exception();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
//
|
||||||
|
// Class template whose default constructor should be used by optional::swap.
|
||||||
|
// Its copy constructor should be avoided!
|
||||||
|
//
|
||||||
|
template <class T>
|
||||||
|
class template_whose_default_ctor_should_be_used : public base_class_with_forbidden_assignment
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
T data;
|
||||||
|
explicit template_whose_default_ctor_should_be_used(T arg) : data(arg) { }
|
||||||
|
|
||||||
|
template_whose_default_ctor_should_be_used() : data('\0') { }
|
||||||
|
|
||||||
|
template_whose_default_ctor_should_be_used(const template_whose_default_ctor_should_be_used &)
|
||||||
|
{
|
||||||
|
BOOST_CHECK(!"This copy constructor should not be used while swapping!");
|
||||||
|
throw copy_ctor_exception();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
//
|
||||||
|
// Class whose explicit constructor should be used by optional::swap.
|
||||||
|
// Its other constructors should be avoided!
|
||||||
|
//
|
||||||
|
class class_whose_explicit_ctor_should_be_used : public base_class_with_forbidden_assignment
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
char data;
|
||||||
|
explicit class_whose_explicit_ctor_should_be_used(char arg) : data(arg) { }
|
||||||
|
|
||||||
|
class_whose_explicit_ctor_should_be_used()
|
||||||
|
{
|
||||||
|
BOOST_CHECK(!"This default constructor should not be used while swapping!");
|
||||||
|
throw default_ctor_exception();
|
||||||
|
}
|
||||||
|
|
||||||
|
class_whose_explicit_ctor_should_be_used(const class_whose_explicit_ctor_should_be_used &)
|
||||||
|
{
|
||||||
|
BOOST_CHECK(!"This copy constructor should not be used while swapping!");
|
||||||
|
throw copy_ctor_exception();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
void swap(class_whose_default_ctor_should_not_be_used & lhs, class_whose_default_ctor_should_not_be_used & rhs)
|
||||||
|
{
|
||||||
|
std::swap(lhs.data, rhs.data);
|
||||||
|
}
|
||||||
|
|
||||||
|
void swap(class_whose_default_ctor_should_be_used & lhs, class_whose_default_ctor_should_be_used & rhs)
|
||||||
|
{
|
||||||
|
std::swap(lhs.data, rhs.data);
|
||||||
|
}
|
||||||
|
|
||||||
|
void swap(class_without_default_ctor & lhs, class_without_default_ctor & rhs)
|
||||||
|
{
|
||||||
|
std::swap(lhs.data, rhs.data);
|
||||||
|
}
|
||||||
|
|
||||||
|
void swap(class_whose_explicit_ctor_should_be_used & lhs, class_whose_explicit_ctor_should_be_used & rhs)
|
||||||
|
{
|
||||||
|
std::swap(lhs.data, rhs.data);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
void swap(template_whose_default_ctor_should_be_used<T> & lhs, template_whose_default_ctor_should_be_used<T> & rhs)
|
||||||
|
{
|
||||||
|
std::swap(lhs.data, rhs.data);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// optional<T>::swap should be customized when neither the copy constructor
|
||||||
|
// nor the default constructor of T are supposed to be used when swapping, e.g.,
|
||||||
|
// for the following type T = class_whose_explicit_ctor_should_be_used.
|
||||||
|
//
|
||||||
|
void swap(boost::optional<class_whose_explicit_ctor_should_be_used> & x, boost::optional<class_whose_explicit_ctor_should_be_used> & y)
|
||||||
|
{
|
||||||
|
bool hasX = x;
|
||||||
|
bool hasY = y;
|
||||||
|
|
||||||
|
if ( !hasX && !hasY )
|
||||||
|
return;
|
||||||
|
|
||||||
|
if( !hasX )
|
||||||
|
x = boost::in_place('\0');
|
||||||
|
else if ( !hasY )
|
||||||
|
y = boost::in_place('\0');
|
||||||
|
|
||||||
|
optional_swap_test::swap(*x,*y);
|
||||||
|
|
||||||
|
if( !hasX )
|
||||||
|
y = boost::none ;
|
||||||
|
else if( !hasY )
|
||||||
|
x = boost::none ;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
} // End of namespace optional_swap_test.
|
||||||
|
|
||||||
|
|
||||||
|
namespace boost {
|
||||||
|
|
||||||
|
//
|
||||||
|
// Compile time tweaking on whether or not swap should use the default constructor:
|
||||||
|
//
|
||||||
|
|
||||||
|
template <> struct optional_swap_should_use_default_constructor<
|
||||||
|
optional_swap_test::class_whose_default_ctor_should_be_used> : mpl::true_ {} ;
|
||||||
|
|
||||||
|
template <> struct optional_swap_should_use_default_constructor<
|
||||||
|
optional_swap_test::class_whose_default_ctor_should_not_be_used> : mpl::false_ {} ;
|
||||||
|
|
||||||
|
template <class T> struct optional_swap_should_use_default_constructor<
|
||||||
|
optional_swap_test::template_whose_default_ctor_should_be_used<T> > : mpl::true_ {} ;
|
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
// Specialization of boost::swap:
|
||||||
|
//
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
optional_swap_test::swap(x, y);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace boost
|
||||||
|
|
||||||
|
|
||||||
|
namespace std {
|
||||||
|
|
||||||
|
//
|
||||||
|
// Specializations of std::swap:
|
||||||
|
//
|
||||||
|
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
optional_swap_test::swap(x, y);
|
||||||
|
}
|
||||||
|
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
optional_swap_test::swap(x, y);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <>
|
||||||
|
void swap(optional_swap_test::class_without_default_ctor & x, optional_swap_test::class_without_default_ctor & y)
|
||||||
|
{
|
||||||
|
optional_swap_test::swap(x, y);
|
||||||
|
}
|
||||||
|
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
optional_swap_test::swap(x, y);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace std
|
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
// Tests whether the swap function works properly for optional<T>.
|
||||||
|
// Assumes that T has one data member, of type char.
|
||||||
|
// Returns true iff the test is passed.
|
||||||
|
//
|
||||||
|
template <class T>
|
||||||
|
bool test_swap_function( T const* )
|
||||||
|
{
|
||||||
|
const boost::unit_test::counter_t counter_before_test = boost::minimal_test::errors_counter();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
optional<T> obj1;
|
||||||
|
optional<T> obj2('a');
|
||||||
|
|
||||||
|
// Self-swap should not have any effect.
|
||||||
|
swap(obj1, obj1);
|
||||||
|
swap(obj2, obj2);
|
||||||
|
BOOST_CHECK(!obj1);
|
||||||
|
BOOST_CHECK(!!obj2 && obj2->data == 'a');
|
||||||
|
|
||||||
|
// Call non-member swap.
|
||||||
|
swap(obj1, obj2);
|
||||||
|
|
||||||
|
// Test if obj1 and obj2 are really swapped.
|
||||||
|
BOOST_CHECK(!!obj1 && obj1->data == 'a');
|
||||||
|
BOOST_CHECK(!obj2);
|
||||||
|
|
||||||
|
// Call non-member swap one more time.
|
||||||
|
swap(obj1, obj2);
|
||||||
|
|
||||||
|
// Test if obj1 and obj2 are swapped back.
|
||||||
|
BOOST_CHECK(!obj1);
|
||||||
|
BOOST_CHECK(!!obj2 && obj2->data == 'a');
|
||||||
|
}
|
||||||
|
catch(const std::exception &)
|
||||||
|
{
|
||||||
|
// The swap function should not throw, for our test cases.
|
||||||
|
return false ;
|
||||||
|
}
|
||||||
|
return boost::minimal_test::errors_counter() == counter_before_test ;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Tests whether the optional<T>::swap member function works properly.
|
||||||
|
// Assumes that T has one data member, of type char.
|
||||||
|
// Returns true iff the test is passed.
|
||||||
|
//
|
||||||
|
template <class T>
|
||||||
|
bool test_swap_member_function( T const* )
|
||||||
|
{
|
||||||
|
const boost::unit_test::counter_t counter_before_test = boost::minimal_test::errors_counter();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
optional<T> obj1;
|
||||||
|
optional<T> obj2('a');
|
||||||
|
|
||||||
|
// Self-swap should not have any effect.
|
||||||
|
obj1.swap(obj1);
|
||||||
|
obj2.swap(obj2);
|
||||||
|
BOOST_CHECK(!obj1);
|
||||||
|
BOOST_CHECK(!!obj2 && obj2->data == 'a');
|
||||||
|
|
||||||
|
// Call member swap.
|
||||||
|
obj1.swap(obj2);
|
||||||
|
|
||||||
|
// Test if obj1 and obj2 are really swapped.
|
||||||
|
BOOST_CHECK(!!obj1 && obj1->data == 'a');
|
||||||
|
BOOST_CHECK(!obj2);
|
||||||
|
|
||||||
|
// Call member swap one more time.
|
||||||
|
obj1.swap(obj2);
|
||||||
|
|
||||||
|
// Test if obj1 and obj2 are swapped back.
|
||||||
|
BOOST_CHECK(!obj1);
|
||||||
|
BOOST_CHECK(!!obj2 && obj2->data == 'a');
|
||||||
|
}
|
||||||
|
catch(const std::exception &)
|
||||||
|
{
|
||||||
|
// The optional<T>::swap member function should not throw, for our test cases.
|
||||||
|
return false ;
|
||||||
|
}
|
||||||
|
return boost::minimal_test::errors_counter() == counter_before_test ;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
// Tests compile time tweaking of swap, by means of
|
||||||
|
// optional_swap_should_use_default_constructor.
|
||||||
|
//
|
||||||
|
void test_swap_tweaking()
|
||||||
|
{
|
||||||
|
BOOST_CHECK( test_swap_function( ARG(optional_swap_test::class_without_default_ctor) ) );
|
||||||
|
BOOST_CHECK( test_swap_function( ARG(optional_swap_test::class_whose_default_ctor_should_be_used) ) );
|
||||||
|
BOOST_CHECK( test_swap_function( ARG(optional_swap_test::class_whose_default_ctor_should_not_be_used) ) );
|
||||||
|
BOOST_CHECK( test_swap_function( ARG(optional_swap_test::class_whose_explicit_ctor_should_be_used) ) );
|
||||||
|
BOOST_CHECK( test_swap_function( ARG(optional_swap_test::template_whose_default_ctor_should_be_used<char>) ) );
|
||||||
|
BOOST_CHECK( test_swap_member_function( ARG(optional_swap_test::class_without_default_ctor) ) );
|
||||||
|
BOOST_CHECK( test_swap_member_function( ARG(optional_swap_test::class_whose_default_ctor_should_be_used) ) );
|
||||||
|
BOOST_CHECK( test_swap_member_function( ARG(optional_swap_test::class_whose_default_ctor_should_not_be_used) ) );
|
||||||
|
BOOST_CHECK( test_swap_member_function( ARG(optional_swap_test::class_whose_explicit_ctor_should_be_used) ) );
|
||||||
|
BOOST_CHECK( test_swap_member_function( ARG(optional_swap_test::template_whose_default_ctor_should_be_used<char>) ) );
|
||||||
|
}
|
||||||
|
|
||||||
int test_main( int, char* [] )
|
int test_main( int, char* [] )
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@ -936,6 +1272,7 @@ int test_main( int, char* [] )
|
|||||||
test_no_implicit_conversions();
|
test_no_implicit_conversions();
|
||||||
test_conversions1();
|
test_conversions1();
|
||||||
test_conversions2();
|
test_conversions2();
|
||||||
|
test_swap_tweaking();
|
||||||
}
|
}
|
||||||
catch ( ... )
|
catch ( ... )
|
||||||
{
|
{
|
||||||
|
@ -1,23 +0,0 @@
|
|||||||
// Copyright (C) 2003, Fernando Luis Cacciola Carballal.
|
|
||||||
//
|
|
||||||
// Use, modification, and distribution is subject to the Boost Software
|
|
||||||
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
|
||||||
// http://www.boost.org/LICENSE_1_0.txt)
|
|
||||||
//
|
|
||||||
// See http://www.boost.org/lib/optional for documentation.
|
|
||||||
//
|
|
||||||
// You are welcome to contact the author at:
|
|
||||||
// fernando_cacciola@hotmail.com
|
|
||||||
//
|
|
||||||
#include "boost/optional.hpp"
|
|
||||||
|
|
||||||
//
|
|
||||||
// THIS TEST SHOULD FAIL TO COMPILE
|
|
||||||
//
|
|
||||||
void optional_reference__test_no_ptr_access()
|
|
||||||
{
|
|
||||||
boost::optional<int&> opt ;
|
|
||||||
opt.get_ptr();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|