mirror of
https://github.com/boostorg/optional.git
synced 2025-07-29 20:17:21 +02:00
Merge branch 'develop'
This commit is contained in:
@ -463,10 +463,11 @@ __SPACE__
|
||||
|
||||
* [*Requires:] `T` is __COPY_CONSTRUCTIBLE__ and `CopyAssignable`.
|
||||
* [*Effects:]
|
||||
[table
|
||||
[[][`*this` contains a value][`*this` does not contain a value]]
|
||||
[[`rhs` contains a value][assigns `*rhs` to the contained value][initializes the contained value as if direct-initializing an object of type `T` with `*rhs`]]
|
||||
[[`rhs` does not contain a value][destroys the contained value by calling `val->T::~T()`][no effect]]
|
||||
[table
|
||||
[]
|
||||
[[][[*`*this` contains a value]][[*`*this` does not contain a value]]]
|
||||
[[[*`rhs` contains a value]][assigns `*rhs` to the contained value][initializes the contained value as if direct-initializing an object of type `T` with `*rhs`]]
|
||||
[[[*`rhs` does not contain a value]][destroys the contained value by calling `val->T::~T()`][no effect]]
|
||||
]
|
||||
* [*Returns:] `*this`;
|
||||
* [*Postconditions:] `bool(rhs) == bool(*this)`.
|
||||
@ -525,9 +526,10 @@ __SPACE__
|
||||
* [*Requires:] `T` is __MOVE_CONSTRUCTIBLE__ and `MoveAssignable`.
|
||||
* [*Effects:]
|
||||
[table
|
||||
[[][`*this` contains a value][`*this` does not contain a value]]
|
||||
[[`rhs` contains a value][assigns `std::move(*rhs)` to the contained value][initializes the contained value as if direct-initializing an object of type `T` with `std::move(*rhs)`]]
|
||||
[[`rhs` does not contain a value][destroys the contained value by calling `val->T::~T()`][no effect]]
|
||||
[]
|
||||
[[][[*`*this` contains a value]][[*`*this` does not contain a value]]]
|
||||
[[[*`rhs` contains a value]][assigns `std::move(*rhs)` to the contained value][initializes the contained value as if direct-initializing an object of type `T` with `std::move(*rhs)`]]
|
||||
[[[*`rhs` does not contain a value]][destroys the contained value by calling `val->T::~T()`][no effect]]
|
||||
]
|
||||
* [*Returns:] `*this`;
|
||||
* [*Postconditions:] `bool(rhs) == bool(*this)`.
|
||||
@ -561,9 +563,10 @@ __SPACE__
|
||||
|
||||
* [*Effect:]
|
||||
[table
|
||||
[[][`*this` contains a value][`*this` does not contain a value]]
|
||||
[[`rhs` contains a value][assigns `*rhs` to the contained value][initializes the contained value as if direct-initializing an object of type `T` with `*rhs`]]
|
||||
[[`rhs` does not contain a value][destroys the contained value by calling `val->T::~T()`][no effect]]
|
||||
[]
|
||||
[[][[*`*this` contains a value]][[*`*this` does not contain a value]]]
|
||||
[[[*`rhs` contains a value]][assigns `*rhs` to the contained value][initializes the contained value as if direct-initializing an object of type `T` with `*rhs`]]
|
||||
[[[*`rhs` does not contain a value]][destroys the contained value by calling `val->T::~T()`][no effect]]
|
||||
]
|
||||
* [*Returns:] `*this`.
|
||||
* [*Postconditions:] `bool(rhs) == bool(*this)`.
|
||||
@ -587,10 +590,11 @@ __SPACE__
|
||||
[: `template<U> optional& optional<T` ['(not a ref)]`>::operator= ( optional<U>&& rhs ) ;`]
|
||||
|
||||
* [*Effect:]
|
||||
[table
|
||||
[[][`*this` contains a value][`*this` does not contain a value]]
|
||||
[[`rhs` contains a value][assigns `std::move(*rhs)` to the contained value][initializes the contained value as if direct-initializing an object of type `T` with `std::move(*rhs)`]]
|
||||
[[`rhs` does not contain a value][destroys the contained value by calling `val->T::~T()`][no effect]]
|
||||
[table
|
||||
[]
|
||||
[[][[*`*this` contains a value]][[*`*this` does not contain a value]]]
|
||||
[[[*`rhs` contains a value]][assigns `std::move(*rhs)` to the contained value][initializes the contained value as if direct-initializing an object of type `T` with `std::move(*rhs)`]]
|
||||
[[[*`rhs` does not contain a value]][destroys the contained value by calling `val->T::~T()`][no effect]]
|
||||
]
|
||||
* [*Returns:] `*this`.
|
||||
* [*Postconditions:] `bool(rhs) == bool(*this)`.
|
||||
@ -621,8 +625,10 @@ __SPACE__
|
||||
of type `T` with `std::forward<Args>(args)...`.
|
||||
* [*Postconditions: ] `*this` is [_initialized].
|
||||
* [*Throws:] Whatever the selected `T`'s constructor throws.
|
||||
* [*Notes:] `T` need not be __MOVE_CONSTRUCTIBLE__ or `MoveAssignable`. On compilers that do not support variadic templates, the signature falls back to single-argument: `template<class Arg> void emplace(Arg&& arg)`. On compilers that do not support rvalue references, the signature falls back to two overloads: taking `const` and non-`const` lvalue reference.
|
||||
* [*Exception Safety:] If an exception is thrown during the initialization of `T`, `*this` is ['uninitialized].
|
||||
* [*Notes:] `T` need not be __MOVE_CONSTRUCTIBLE__ or `MoveAssignable`.
|
||||
On compilers that do not support variadic templates, the signature falls back to two overloads:`template<class Arg> void emplace(Arg&& arg)` and `void emplace()`.
|
||||
On compilers that do not support rvalue references, the signature falls back to three overloads: taking `const` and non-`const` lvalue reference, and third with empty function argument list.
|
||||
* [*Example:]
|
||||
``
|
||||
T v;
|
||||
@ -1111,9 +1117,10 @@ __SPACE__
|
||||
* [*Requires:] Lvalues of type `T` shall be swappable and `T` shall be __MOVE_CONSTRUCTIBLE__.
|
||||
* [*Effects:]
|
||||
[table
|
||||
[[][`*this` contains a value][`*this` does not contain a value]]
|
||||
[[`rhs` contains a value][calls `swap(*(*this), *rhs)`][initializes the contained value of `*this` as if direct-initializing an object of type `T` with the expression `std::move(*rhs)`, followed by `rhs.val->T::~T()`, `*this` contains a value and `rhs` does not contain a value]]
|
||||
[[`rhs` does not contain a value][initializes the contained value of `rhs` as if direct-initializing an object of type `T` with the expression `std::move(*(*this))`, followed by `val->T::~T()`, `*this` does not contain a value and `rhs` contains a value][no effect]]
|
||||
[]
|
||||
[[][[*`*this` contains a value]][[*`*this` does not contain a value]]]
|
||||
[[[*`rhs` contains a value]][calls `swap(*(*this), *rhs)`][initializes the contained value of `*this` as if direct-initializing an object of type `T` with the expression `std::move(*rhs)`, followed by `rhs.val->T::~T()`, `*this` contains a value and `rhs` does not contain a value]]
|
||||
[[[*`rhs` does not contain a value]][initializes the contained value of `rhs` as if direct-initializing an object of type `T` with the expression `std::move(*(*this))`, followed by `val->T::~T()`, `*this` does not contain a value and `rhs` contains a value][no effect]]
|
||||
]
|
||||
* [*Postconditions:] The states of `x` and `y` interchanged.
|
||||
* [*Throws:] If both are initialized, whatever `swap(T&,T&)` throws. If only
|
||||
|
@ -11,12 +11,16 @@
|
||||
|
||||
[section:relnotes Release Notes]
|
||||
|
||||
[heading Boost Release 1.59]
|
||||
|
||||
* For C++03 compilers, added 0-argument overload for member function `emplace()`, and therewith removed the dependency on `<boost/utility/in_place_factory.hpp>`.
|
||||
|
||||
[heading Boost Release 1.58]
|
||||
|
||||
* `boost::none_t` is no longer convertible from literal `0`. This avoids a bug where `optional<rational<int>> oi = 0;` would initialize an optional object with no contained value.
|
||||
* Improved the trick that prevents streaming out `optional` without header `optional_io.hpp` by using safe-bool idiom. This addresses [@https://svn.boost.org/trac/boost/ticket/10825 Trac #10825]
|
||||
* Improved the trick that prevents streaming out `optional` without header `optional_io.hpp` by using safe-bool idiom. This addresses [@https://svn.boost.org/trac/boost/ticket/10825 Trac #10825].
|
||||
* IOStream operators are now mentioned in documentation.
|
||||
* Added a way to manually disable move semantics: just define macro `BOOST_OPTIONAL_CONFIG_NO_RVALUE_REFERENCES`. This can be used to work around [@https://svn.boost.org/trac/boost/ticket/10399 Trac #10399]
|
||||
* Added a way to manually disable move semantics: just define macro `BOOST_OPTIONAL_CONFIG_NO_RVALUE_REFERENCES`. This can be used to work around [@https://svn.boost.org/trac/boost/ticket/10399 Trac #10399].
|
||||
* It is no longer possible to assign `optional<U>` to `optional<T>` when `U` is not assignable or convertible to `T` ([@https://svn.boost.org/trac/boost/ticket/11087 Trac #11087]).
|
||||
* Value accessors now work correctly on rvalues of `optional<T&>` ([@https://svn.boost.org/trac/boost/ticket/10839 Trac #10839]).
|
||||
|
||||
|
@ -838,28 +838,27 @@
|
||||
<col>
|
||||
<col>
|
||||
</colgroup>
|
||||
<thead><tr>
|
||||
<th>
|
||||
</th>
|
||||
<th>
|
||||
<p>
|
||||
<code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code>
|
||||
contains a value
|
||||
</p>
|
||||
</th>
|
||||
<th>
|
||||
<p>
|
||||
<code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code>
|
||||
does not contain a value
|
||||
</p>
|
||||
</th>
|
||||
</tr></thead>
|
||||
<thead><tr></tr></thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
<code class="computeroutput"><span class="identifier">rhs</span></code> contains
|
||||
a value
|
||||
<span class="bold"><strong><code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> contains a value</strong></span>
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
<span class="bold"><strong><code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> does not contain a value</strong></span>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
<span class="bold"><strong><code class="computeroutput"><span class="identifier">rhs</span></code>
|
||||
contains a value</strong></span>
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
@ -879,8 +878,8 @@
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
<code class="computeroutput"><span class="identifier">rhs</span></code> does
|
||||
not contain a value
|
||||
<span class="bold"><strong><code class="computeroutput"><span class="identifier">rhs</span></code>
|
||||
does not contain a value</strong></span>
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
@ -995,28 +994,27 @@
|
||||
<col>
|
||||
<col>
|
||||
</colgroup>
|
||||
<thead><tr>
|
||||
<th>
|
||||
</th>
|
||||
<th>
|
||||
<p>
|
||||
<code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code>
|
||||
contains a value
|
||||
</p>
|
||||
</th>
|
||||
<th>
|
||||
<p>
|
||||
<code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code>
|
||||
does not contain a value
|
||||
</p>
|
||||
</th>
|
||||
</tr></thead>
|
||||
<thead><tr></tr></thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
<code class="computeroutput"><span class="identifier">rhs</span></code> contains
|
||||
a value
|
||||
<span class="bold"><strong><code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> contains a value</strong></span>
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
<span class="bold"><strong><code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> does not contain a value</strong></span>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
<span class="bold"><strong><code class="computeroutput"><span class="identifier">rhs</span></code>
|
||||
contains a value</strong></span>
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
@ -1035,8 +1033,8 @@
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
<code class="computeroutput"><span class="identifier">rhs</span></code> does
|
||||
not contain a value
|
||||
<span class="bold"><strong><code class="computeroutput"><span class="identifier">rhs</span></code>
|
||||
does not contain a value</strong></span>
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
@ -1117,28 +1115,27 @@
|
||||
<col>
|
||||
<col>
|
||||
</colgroup>
|
||||
<thead><tr>
|
||||
<th>
|
||||
</th>
|
||||
<th>
|
||||
<p>
|
||||
<code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code>
|
||||
contains a value
|
||||
</p>
|
||||
</th>
|
||||
<th>
|
||||
<p>
|
||||
<code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code>
|
||||
does not contain a value
|
||||
</p>
|
||||
</th>
|
||||
</tr></thead>
|
||||
<thead><tr></tr></thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
<code class="computeroutput"><span class="identifier">rhs</span></code> contains
|
||||
a value
|
||||
<span class="bold"><strong><code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> contains a value</strong></span>
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
<span class="bold"><strong><code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> does not contain a value</strong></span>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
<span class="bold"><strong><code class="computeroutput"><span class="identifier">rhs</span></code>
|
||||
contains a value</strong></span>
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
@ -1158,8 +1155,8 @@
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
<code class="computeroutput"><span class="identifier">rhs</span></code> does
|
||||
not contain a value
|
||||
<span class="bold"><strong><code class="computeroutput"><span class="identifier">rhs</span></code>
|
||||
does not contain a value</strong></span>
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
@ -1222,28 +1219,27 @@
|
||||
<col>
|
||||
<col>
|
||||
</colgroup>
|
||||
<thead><tr>
|
||||
<th>
|
||||
</th>
|
||||
<th>
|
||||
<p>
|
||||
<code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code>
|
||||
contains a value
|
||||
</p>
|
||||
</th>
|
||||
<th>
|
||||
<p>
|
||||
<code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code>
|
||||
does not contain a value
|
||||
</p>
|
||||
</th>
|
||||
</tr></thead>
|
||||
<thead><tr></tr></thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
<code class="computeroutput"><span class="identifier">rhs</span></code> contains
|
||||
a value
|
||||
<span class="bold"><strong><code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> contains a value</strong></span>
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
<span class="bold"><strong><code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> does not contain a value</strong></span>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
<span class="bold"><strong><code class="computeroutput"><span class="identifier">rhs</span></code>
|
||||
contains a value</strong></span>
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
@ -1262,8 +1258,8 @@
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
<code class="computeroutput"><span class="identifier">rhs</span></code> does
|
||||
not contain a value
|
||||
<span class="bold"><strong><code class="computeroutput"><span class="identifier">rhs</span></code>
|
||||
does not contain a value</strong></span>
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
@ -1336,23 +1332,26 @@
|
||||
<li class="listitem">
|
||||
<span class="bold"><strong>Throws:</strong></span> Whatever the selected <code class="computeroutput"><span class="identifier">T</span></code>'s constructor throws.
|
||||
</li>
|
||||
<li class="listitem">
|
||||
<span class="bold"><strong>Notes:</strong></span> <code class="computeroutput"><span class="identifier">T</span></code>
|
||||
need not be <code class="computeroutput"><span class="identifier">MoveConstructible</span></code>
|
||||
or <code class="computeroutput"><span class="identifier">MoveAssignable</span></code>.
|
||||
On compilers that do not support variadic templates, the signature
|
||||
falls back to single-argument: <code class="computeroutput"><span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span>
|
||||
<span class="identifier">Arg</span><span class="special">></span>
|
||||
<span class="keyword">void</span> <span class="identifier">emplace</span><span class="special">(</span><span class="identifier">Arg</span><span class="special">&&</span> <span class="identifier">arg</span><span class="special">)</span></code>. On compilers that do not support
|
||||
rvalue references, the signature falls back to two overloads: taking
|
||||
<code class="computeroutput"><span class="keyword">const</span></code> and non-<code class="computeroutput"><span class="keyword">const</span></code> lvalue reference.
|
||||
</li>
|
||||
<li class="listitem">
|
||||
<span class="bold"><strong>Exception Safety:</strong></span> If an exception
|
||||
is thrown during the initialization of <code class="computeroutput"><span class="identifier">T</span></code>,
|
||||
<code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code>
|
||||
is <span class="emphasis"><em>uninitialized</em></span>.
|
||||
</li>
|
||||
<li class="listitem">
|
||||
<span class="bold"><strong>Notes:</strong></span> <code class="computeroutput"><span class="identifier">T</span></code>
|
||||
need not be <code class="computeroutput"><span class="identifier">MoveConstructible</span></code>
|
||||
or <code class="computeroutput"><span class="identifier">MoveAssignable</span></code>.
|
||||
On compilers that do not support variadic templates, the signature
|
||||
falls back to two overloads:<code class="computeroutput"><span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span>
|
||||
<span class="identifier">Arg</span><span class="special">></span>
|
||||
<span class="keyword">void</span> <span class="identifier">emplace</span><span class="special">(</span><span class="identifier">Arg</span><span class="special">&&</span> <span class="identifier">arg</span><span class="special">)</span></code> and <code class="computeroutput"><span class="keyword">void</span>
|
||||
<span class="identifier">emplace</span><span class="special">()</span></code>.
|
||||
On compilers that do not support rvalue references, the signature falls
|
||||
back to three overloads: taking <code class="computeroutput"><span class="keyword">const</span></code>
|
||||
and non-<code class="computeroutput"><span class="keyword">const</span></code> lvalue reference,
|
||||
and third with empty function argument list.
|
||||
</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>
|
||||
@ -2271,28 +2270,27 @@
|
||||
<col>
|
||||
<col>
|
||||
</colgroup>
|
||||
<thead><tr>
|
||||
<th>
|
||||
</th>
|
||||
<th>
|
||||
<p>
|
||||
<code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code>
|
||||
contains a value
|
||||
</p>
|
||||
</th>
|
||||
<th>
|
||||
<p>
|
||||
<code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code>
|
||||
does not contain a value
|
||||
</p>
|
||||
</th>
|
||||
</tr></thead>
|
||||
<thead><tr></tr></thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
<code class="computeroutput"><span class="identifier">rhs</span></code> contains
|
||||
a value
|
||||
<span class="bold"><strong><code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> contains a value</strong></span>
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
<span class="bold"><strong><code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> does not contain a value</strong></span>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
<span class="bold"><strong><code class="computeroutput"><span class="identifier">rhs</span></code>
|
||||
contains a value</strong></span>
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
@ -2314,8 +2312,8 @@
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
<code class="computeroutput"><span class="identifier">rhs</span></code> does
|
||||
not contain a value
|
||||
<span class="bold"><strong><code class="computeroutput"><span class="identifier">rhs</span></code>
|
||||
does not contain a value</strong></span>
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
|
@ -28,6 +28,15 @@
|
||||
</h2></div></div></div>
|
||||
<h4>
|
||||
<a name="boost_optional.relnotes.h0"></a>
|
||||
<span class="phrase"><a name="boost_optional.relnotes.boost_release_1_59"></a></span><a class="link" href="relnotes.html#boost_optional.relnotes.boost_release_1_59">Boost
|
||||
Release 1.59</a>
|
||||
</h4>
|
||||
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
|
||||
For C++03 compilers, added 0-argument overload for member function <code class="computeroutput"><span class="identifier">emplace</span><span class="special">()</span></code>,
|
||||
and therewith removed the dependency on <code class="computeroutput"><span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">utility</span><span class="special">/</span><span class="identifier">in_place_factory</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span></code>.
|
||||
</li></ul></div>
|
||||
<h4>
|
||||
<a name="boost_optional.relnotes.h1"></a>
|
||||
<span class="phrase"><a name="boost_optional.relnotes.boost_release_1_58"></a></span><a class="link" href="relnotes.html#boost_optional.relnotes.boost_release_1_58">Boost
|
||||
Release 1.58</a>
|
||||
</h4>
|
||||
@ -42,7 +51,7 @@
|
||||
Improved the trick that prevents streaming out <code class="computeroutput"><span class="identifier">optional</span></code>
|
||||
without header <code class="computeroutput"><span class="identifier">optional_io</span><span class="special">.</span><span class="identifier">hpp</span></code>
|
||||
by using safe-bool idiom. This addresses <a href="https://svn.boost.org/trac/boost/ticket/10825" target="_top">Trac
|
||||
#10825</a>
|
||||
#10825</a>.
|
||||
</li>
|
||||
<li class="listitem">
|
||||
IOStream operators are now mentioned in documentation.
|
||||
@ -50,7 +59,7 @@
|
||||
<li class="listitem">
|
||||
Added a way to manually disable move semantics: just define macro <code class="computeroutput"><span class="identifier">BOOST_OPTIONAL_CONFIG_NO_RVALUE_REFERENCES</span></code>.
|
||||
This can be used to work around <a href="https://svn.boost.org/trac/boost/ticket/10399" target="_top">Trac
|
||||
#10399</a>
|
||||
#10399</a>.
|
||||
</li>
|
||||
<li class="listitem">
|
||||
It is no longer possible to assign <code class="computeroutput"><span class="identifier">optional</span><span class="special"><</span><span class="identifier">U</span><span class="special">></span></code> to <code class="computeroutput"><span class="identifier">optional</span><span class="special"><</span><span class="identifier">T</span><span class="special">></span></code> when <code class="computeroutput"><span class="identifier">U</span></code>
|
||||
@ -63,7 +72,7 @@
|
||||
</li>
|
||||
</ul></div>
|
||||
<h4>
|
||||
<a name="boost_optional.relnotes.h1"></a>
|
||||
<a name="boost_optional.relnotes.h2"></a>
|
||||
<span class="phrase"><a name="boost_optional.relnotes.boost_release_1_57"></a></span><a class="link" href="relnotes.html#boost_optional.relnotes.boost_release_1_57">Boost
|
||||
Release 1.57</a>
|
||||
</h4>
|
||||
@ -73,7 +82,7 @@
|
||||
to fix C++03 compile error on <code class="computeroutput"><span class="identifier">logic_error</span><span class="special">(</span><span class="string">"..."</span><span class="special">)</span></code>"</em></span>.
|
||||
</li></ul></div>
|
||||
<h4>
|
||||
<a name="boost_optional.relnotes.h2"></a>
|
||||
<a name="boost_optional.relnotes.h3"></a>
|
||||
<span class="phrase"><a name="boost_optional.relnotes.boost_release_1_56"></a></span><a class="link" href="relnotes.html#boost_optional.relnotes.boost_release_1_56">Boost
|
||||
Release 1.56</a>
|
||||
</h4>
|
||||
|
@ -146,7 +146,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||||
<td align="left"><p><small>Last revised: March 13, 2015 at 21:52:15 GMT</small></p></td>
|
||||
<td align="left"><p><small>Last revised: July 08, 2015 at 21:39:55 GMT</small></p></td>
|
||||
<td align="right"><div class="copyright-footer"></div></td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
|
@ -18,12 +18,14 @@
|
||||
#define BOOST_OPTIONAL_OPTIONAL_FLC_19NOV2002_HPP
|
||||
|
||||
#include <new>
|
||||
#include <algorithm>
|
||||
#include <iosfwd>
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/assert.hpp>
|
||||
#include <boost/core/addressof.hpp>
|
||||
#include <boost/core/enable_if.hpp>
|
||||
#include <boost/core/explicit_operator_bool.hpp>
|
||||
#include <boost/core/swap.hpp>
|
||||
#include <boost/optional/bad_optional_access.hpp>
|
||||
#include <boost/static_assert.hpp>
|
||||
#include <boost/throw_exception.hpp>
|
||||
@ -47,13 +49,7 @@
|
||||
#include <boost/detail/reference_content.hpp>
|
||||
#include <boost/move/utility.hpp>
|
||||
#include <boost/none.hpp>
|
||||
#include <boost/utility/addressof.hpp>
|
||||
#include <boost/utility/compare_pointees.hpp>
|
||||
#include <boost/utility/enable_if.hpp>
|
||||
#include <boost/utility/in_place_factory.hpp>
|
||||
#include <boost/utility/swap.hpp>
|
||||
|
||||
|
||||
|
||||
#include <boost/optional/optional_fwd.hpp>
|
||||
|
||||
@ -506,6 +502,13 @@ class optional_base : public optional_tag
|
||||
::new (m_storage.address()) internal_type( boost::forward<Arg>(arg) );
|
||||
m_initialized = true ;
|
||||
}
|
||||
|
||||
void emplace_assign ()
|
||||
{
|
||||
destroy();
|
||||
::new (m_storage.address()) internal_type();
|
||||
m_initialized = true ;
|
||||
}
|
||||
#else
|
||||
template<class Arg>
|
||||
void emplace_assign ( const Arg& arg )
|
||||
@ -515,13 +518,20 @@ class optional_base : public optional_tag
|
||||
m_initialized = true ;
|
||||
}
|
||||
|
||||
template<class Arg>
|
||||
template<class Arg>
|
||||
void emplace_assign ( Arg& arg )
|
||||
{
|
||||
destroy();
|
||||
::new (m_storage.address()) internal_type( arg );
|
||||
m_initialized = true ;
|
||||
}
|
||||
|
||||
void emplace_assign ()
|
||||
{
|
||||
destroy();
|
||||
::new (m_storage.address()) internal_type();
|
||||
m_initialized = true ;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef BOOST_OPTIONAL_NO_INPLACE_FACTORY_SUPPORT
|
||||
@ -976,6 +986,11 @@ class optional : public optional_detail::optional_base<T>
|
||||
{
|
||||
this->emplace_assign( boost::forward<Arg>(arg) );
|
||||
}
|
||||
|
||||
void emplace ()
|
||||
{
|
||||
this->emplace_assign();
|
||||
}
|
||||
#else
|
||||
template<class Arg>
|
||||
void emplace ( const Arg& arg )
|
||||
@ -988,6 +1003,11 @@ class optional : public optional_detail::optional_base<T>
|
||||
{
|
||||
this->emplace_assign( arg );
|
||||
}
|
||||
|
||||
void emplace ()
|
||||
{
|
||||
this->emplace_assign();
|
||||
}
|
||||
#endif
|
||||
|
||||
void swap( optional & arg )
|
||||
@ -1251,9 +1271,10 @@ get_pointer ( optional<T>& opt )
|
||||
// The following declaration prevents a bug where operator safe-bool is used upon streaming optional object if you forget the IO header.
|
||||
template<class CharType, class CharTrait>
|
||||
std::basic_ostream<CharType, CharTrait>&
|
||||
operator<<(std::basic_ostream<CharType, CharTrait>& out, optional_detail::optional_tag const& v)
|
||||
operator<<(std::basic_ostream<CharType, CharTrait>& os, optional_detail::optional_tag const&)
|
||||
{
|
||||
BOOST_STATIC_ASSERT_MSG(sizeof(CharType) == 0, "If you want to output boost::optional, include header <boost/optional/optional_io.hpp>");
|
||||
BOOST_STATIC_ASSERT_MSG(sizeof(CharType) == 0, "If you want to output boost::optional, include header <boost/optional/optional_io.hpp>");
|
||||
return os;
|
||||
}
|
||||
|
||||
// optional's relational operators ( ==, !=, <, >, <=, >= ) have deep-semantics (compare values).
|
||||
@ -1448,9 +1469,9 @@ struct swap_selector<true>
|
||||
return;
|
||||
|
||||
if( !hasX )
|
||||
x = boost::in_place();
|
||||
x.emplace();
|
||||
else if ( !hasY )
|
||||
y = boost::in_place();
|
||||
y.emplace();
|
||||
|
||||
// Boost.Utility.Swap will take care of ADL and workarounds for broken compilers
|
||||
boost::swap(x.get(),y.get());
|
||||
@ -1523,9 +1544,18 @@ struct swap_selector<false>
|
||||
|
||||
} // namespace optional_detail
|
||||
|
||||
#if (!defined BOOST_NO_CXX11_RVALUE_REFERENCES) && (!defined BOOST_CONFIG_RESTORE_OBSOLETE_SWAP_IMPLEMENTATION)
|
||||
|
||||
template<class T>
|
||||
struct optional_swap_should_use_default_constructor : boost::false_type {} ;
|
||||
|
||||
#else
|
||||
|
||||
template<class T>
|
||||
struct optional_swap_should_use_default_constructor : has_nothrow_default_constructor<T> {} ;
|
||||
|
||||
#endif //BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||
|
||||
template<class T> inline void swap ( optional<T>& x, optional<T>& y )
|
||||
//BOOST_NOEXCEPT_IF(::boost::is_nothrow_move_constructible<T>::value && BOOST_NOEXCEPT_EXPR(boost::swap(*x, *y)))
|
||||
{
|
||||
|
@ -1,15 +1,16 @@
|
||||
# Boost.Optional Library test Jamfile
|
||||
# Boost.Optional Library test Jamfile
|
||||
#
|
||||
# Copyright (C) 2003, Fernando Luis Cacciola Carballal.
|
||||
# Copyright (C) 2003, Fernando Luis Cacciola Carballal.
|
||||
# Copyright (C) 2014, 2015 Andrzej Krzemienski
|
||||
#
|
||||
# This material is provided "as is", with absolutely no warranty expressed
|
||||
# or implied. Any use is at your own risk.
|
||||
# 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)
|
||||
#
|
||||
# Permission to use or copy this software for any purpose is hereby granted
|
||||
# without fee, provided the above notices are retained on all copies.
|
||||
# Permission to modify the code and to distribute modified code is granted,
|
||||
# provided the above notices are retained, and a notice that the code was
|
||||
# modified is included with the above copyright notice.
|
||||
# See http://www.boost.org/libs/optional for documentation.
|
||||
#
|
||||
# You are welcome to contact the author at:
|
||||
# akrzemi1@gmail.com
|
||||
#
|
||||
|
||||
import testing ;
|
||||
|
@ -145,25 +145,62 @@ void test_clear_on_throw()
|
||||
|
||||
void test_no_assignment_on_emplacement()
|
||||
{
|
||||
optional<const std::string> os;
|
||||
optional<const std::string> os, ot;
|
||||
BOOST_TEST(!os);
|
||||
os.emplace("wow");
|
||||
BOOST_TEST(os);
|
||||
BOOST_TEST_EQ(*os, "wow");
|
||||
|
||||
BOOST_TEST(!ot);
|
||||
ot.emplace();
|
||||
BOOST_TEST(ot);
|
||||
BOOST_TEST_EQ(*ot, "");
|
||||
}
|
||||
|
||||
namespace no_rvalue_refs {
|
||||
class Guard
|
||||
{
|
||||
public:
|
||||
int which_ctor;
|
||||
Guard () : which_ctor(0) { }
|
||||
Guard (std::string const&) : which_ctor(5) { }
|
||||
Guard (std::string &) : which_ctor(6) { }
|
||||
private:
|
||||
Guard(Guard const&);
|
||||
void operator=(Guard const&);
|
||||
};
|
||||
|
||||
void test_emplace()
|
||||
{
|
||||
const std::string cs;
|
||||
std::string ms;
|
||||
optional<Guard> o;
|
||||
|
||||
o.emplace();
|
||||
BOOST_TEST(o);
|
||||
BOOST_TEST(0 == o->which_ctor);
|
||||
|
||||
o.emplace(cs);
|
||||
BOOST_TEST(o);
|
||||
BOOST_TEST(5 == o->which_ctor);
|
||||
|
||||
o.emplace(ms);
|
||||
BOOST_TEST(o);
|
||||
BOOST_TEST(6 == o->which_ctor);
|
||||
}
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
#if (!defined BOOST_NO_CXX11_RVALUE_REFERENCES) && (!defined BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
||||
test_emplace();
|
||||
test_emplace();
|
||||
#endif
|
||||
#if (!defined BOOST_NO_CXX11_RVALUE_REFERENCES)
|
||||
test_no_moves_on_emplacement();
|
||||
test_no_moves_on_emplacement();
|
||||
#endif
|
||||
test_clear_on_throw();
|
||||
test_no_assignment_on_emplacement();
|
||||
|
||||
return boost::report_errors();
|
||||
test_clear_on_throw();
|
||||
test_no_assignment_on_emplacement();
|
||||
no_rvalue_refs::test_emplace();
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
|
||||
|
@ -21,7 +21,7 @@ using boost::optional;
|
||||
|
||||
|
||||
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||
#ifndef BOOST_NO_NOEXCEPT
|
||||
#ifndef BOOST_NO_CXX11_NOEXCEPT
|
||||
|
||||
// these 4 classes have different noexcept signatures in move operations
|
||||
struct NothrowBoth {
|
||||
@ -105,7 +105,7 @@ void test_noexcept_optional_with_operator() // compile-time test
|
||||
BOOST_STATIC_ASSERT(!BOOST_NOEXCEPT_EXPR( onx0 = ONx0() ));
|
||||
}
|
||||
|
||||
#endif // !defned BOOST_NO_NOEXCEPT
|
||||
#endif // !defned BOOST_NO_CXX11_NOEXCEPT
|
||||
#endif // !defined BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||
|
||||
int main()
|
||||
|
@ -15,6 +15,7 @@
|
||||
//
|
||||
|
||||
#include "boost/optional/optional.hpp"
|
||||
#include "boost/utility/in_place_factory.hpp"
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#pragma hdrstop
|
||||
|
Reference in New Issue
Block a user