forked from boostorg/optional
More restrictive assignment from optional<U>
This commit is contained in:
@@ -602,10 +602,11 @@ __SPACE__
|
|||||||
|
|
||||||
* [*Requires:] `T` is __COPY_CONSTRUCTIBLE__ and `CopyAssignable`.
|
* [*Requires:] `T` is __COPY_CONSTRUCTIBLE__ and `CopyAssignable`.
|
||||||
* [*Effects:]
|
* [*Effects:]
|
||||||
* If `!*this && !rhs` no effect, otherwise
|
[table
|
||||||
* if `bool(*this) && !rhs`, destroys the contained value by calling `val->T::~T()`, otherwise
|
[[][`*this` contains a value][`*this` does not contain a value]]
|
||||||
* if `!*this && bool(rhs)`, initializes the contained value as if direct-initializing an object of type `T` with `*rhs`, otherwise
|
[[`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`]]
|
||||||
* (if `bool(*this) && bool(rhs)`) assigns `*rhs` to the contained value.
|
[[`rhs` does not contain a value][destroys the contained value by calling `val->T::~T()`][no effect]]
|
||||||
|
]
|
||||||
* [*Returns:] `*this`;
|
* [*Returns:] `*this`;
|
||||||
* [*Postconditions:] `bool(rhs) == bool(*this)`.
|
* [*Postconditions:] `bool(rhs) == bool(*this)`.
|
||||||
* [*Exception Safety:] If any exception is thrown, the initialization state of `*this` and `rhs` remains unchanged.
|
* [*Exception Safety:] If any exception is thrown, the initialization state of `*this` and `rhs` remains unchanged.
|
||||||
@@ -662,10 +663,11 @@ __SPACE__
|
|||||||
|
|
||||||
* [*Requires:] `T` is __MOVE_CONSTRUCTIBLE__ and `MoveAssignable`.
|
* [*Requires:] `T` is __MOVE_CONSTRUCTIBLE__ and `MoveAssignable`.
|
||||||
* [*Effects:]
|
* [*Effects:]
|
||||||
* If `!*this && !rhs` no effect, otherwise
|
[table
|
||||||
* if `bool(*this) && !rhs`, destroys the contained value by calling `val->T::~T()`, otherwise
|
[[][`*this` contains a value][`*this` does not contain a value]]
|
||||||
* if `!*this && bool(rhs)`, initializes the contained value as if direct-initializing an object of type `T` with `std::move(*rhs)`, otherwise
|
[[`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)`]]
|
||||||
* (if `bool(*this) && bool(rhs)`) assigns `std::move(*rhs)` to the contained value.
|
[[`rhs` does not contain a value][destroys the contained value by calling `val->T::~T()`][no effect]]
|
||||||
|
]
|
||||||
* [*Returns:] `*this`;
|
* [*Returns:] `*this`;
|
||||||
* [*Postconditions:] `bool(rhs) == bool(*this)`.
|
* [*Postconditions:] `bool(rhs) == bool(*this)`.
|
||||||
* [*Remarks:] The expression inside `noexcept` is equivalent to `is_nothrow_move_constructible<T>::value && is_nothrow_move_assignable<T>::value`.
|
* [*Remarks:] The expression inside `noexcept` is equivalent to `is_nothrow_move_constructible<T>::value && is_nothrow_move_assignable<T>::value`.
|
||||||
@@ -696,21 +698,17 @@ __SPACE__
|
|||||||
|
|
||||||
[: `template<U> optional& optional<T` ['(not a ref)]`>::operator= ( optional<U> const& rhs ) ;`]
|
[: `template<U> optional& optional<T` ['(not a ref)]`>::operator= ( optional<U> const& rhs ) ;`]
|
||||||
|
|
||||||
* [*Effect:] Assigns another convertible optional to an optional.
|
* [*Effect:]
|
||||||
* [*Postconditions:] If `rhs` is initialized, `*this` is initialized and
|
[table
|
||||||
its value is a ['copy] of the value of `rhs` ['converted] to type `T`; else
|
[[][`*this` contains a value][`*this` does not contain a value]]
|
||||||
`*this` is uninitialized.
|
[[`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`]]
|
||||||
* [*Throws:] Whatever `T::operator=( U const& )` or `T::T( U const& )` throws.
|
[[`rhs` does not contain a value][destroys the contained value by calling `val->T::~T()`][no effect]]
|
||||||
* [*Notes:] If both `*this` and rhs are initially initialized, `T`'s
|
]
|
||||||
['assignment operator] (from `U`) is used. If `*this` is initially initialized
|
* [*Returns:] `*this`.
|
||||||
but `rhs` is uninitialized, `T`'s ['destructor] is called. If `*this` is
|
* [*Postconditions:] `bool(rhs) == bool(*this)`.
|
||||||
initially uninitialized but rhs is initialized, `T`'s ['converting constructor]
|
* [*Exception Safety:] If any exception is thrown, the result of the expression `bool(*this)` remains unchanged.
|
||||||
(from `U`) is called.
|
If an exception is thrown during the call to `T`'s constructor, no effect.
|
||||||
* [*Exception Safety:] In the event of an exception, the initialization state
|
If an exception is thrown during the call to `T`'s assignment, the state of its contained value is as defined by the exception safety guarantee of `T`'s copy assignment.
|
||||||
of `*this` is unchanged and its value unspecified as far as optional is
|
|
||||||
concerned (it is up to `T`'s `operator=()`). If `*this` is initially
|
|
||||||
uninitialized and `T`'s converting constructor fails, `*this` is left properly
|
|
||||||
uninitialized.
|
|
||||||
* [*Example:]
|
* [*Example:]
|
||||||
``
|
``
|
||||||
T v;
|
T v;
|
||||||
@@ -727,21 +725,17 @@ __SPACE__
|
|||||||
|
|
||||||
[: `template<U> optional& optional<T` ['(not a ref)]`>::operator= ( optional<U>&& rhs ) ;`]
|
[: `template<U> optional& optional<T` ['(not a ref)]`>::operator= ( optional<U>&& rhs ) ;`]
|
||||||
|
|
||||||
* [*Effect:] Move-assigns another convertible optional to an optional.
|
* [*Effect:]
|
||||||
* [*Postconditions:] If `rhs` is initialized, `*this` is initialized and
|
[table
|
||||||
its value is moved from the value of `rhs`; else
|
[[][`*this` contains a value][`*this` does not contain a value]]
|
||||||
`*this` is uninitialized.
|
[[`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)`]]
|
||||||
* [*Throws:] Whatever `T::operator=( U&& )` or `T::T( U&& )` throws.
|
[[`rhs` does not contain a value][destroys the contained value by calling `val->T::~T()`][no effect]]
|
||||||
* [*Notes:] If both `*this` and `rhs` are initially initialized, `T`'s
|
]
|
||||||
[' assignment operator] (from `U&&`) is used. If `*this` is initially initialized
|
* [*Returns:] `*this`.
|
||||||
but `rhs` is uninitialized, `T`'s ['destructor] is called. If `*this` is
|
* [*Postconditions:] `bool(rhs) == bool(*this)`.
|
||||||
initially uninitialized but `rhs` is initialized, `T`'s ['converting constructor]
|
* [*Exception Safety:] If any exception is thrown, the result of the expression `bool(*this)` remains unchanged.
|
||||||
(from `U&&`) is called.
|
If an exception is thrown during the call to `T`'s constructor, no effect.
|
||||||
* [*Exception Safety:] In the event of an exception, the initialization state
|
If an exception is thrown during the call to `T`'s assignment, the state of its contained value is as defined by the exception safety guarantee of `T`'s copy assignment.
|
||||||
of `*this` is unchanged and its value unspecified as far as optional is
|
|
||||||
concerned (it is up to `T`'s `operator=()`). If `*this` is initially
|
|
||||||
uninitialized and `T`'s converting constructor fails, `*this` is left properly
|
|
||||||
uninitialized.
|
|
||||||
* [*Example:]
|
* [*Example:]
|
||||||
``
|
``
|
||||||
T v;
|
T v;
|
||||||
@@ -1256,10 +1250,11 @@ __SPACE__
|
|||||||
|
|
||||||
* [*Requires:] Lvalues of type `T` shall be swappable and `T` shall be __MOVE_CONSTRUCTIBLE__.
|
* [*Requires:] Lvalues of type `T` shall be swappable and `T` shall be __MOVE_CONSTRUCTIBLE__.
|
||||||
* [*Effects:]
|
* [*Effects:]
|
||||||
* If `!*this && !rhs`, no effect, otherwise
|
[table
|
||||||
* if `bool(*this) && !rhs`, 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, otherwise
|
[[][`*this` contains a value][`*this` does not contain a value]]
|
||||||
* if `!*this && bool(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, otherwise
|
[[`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]]
|
||||||
* (if `bool(*this) && bool(rhs)`) calls `swap(*(*this), *rhs)`.
|
[[`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.
|
* [*Postconditions:] The states of `x` and `y` interchanged.
|
||||||
* [*Throws:] If both are initialized, whatever `swap(T&,T&)` throws. If only
|
* [*Throws:] If both are initialized, whatever `swap(T&,T&)` throws. If only
|
||||||
one is initialized, whatever `T::T ( T&& )` throws.
|
one is initialized, whatever `T::T ( T&& )` throws.
|
||||||
|
@@ -17,6 +17,7 @@
|
|||||||
* 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.
|
* 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`.
|
||||||
|
|
||||||
|
|
||||||
[heading Boost Release 1.57]
|
[heading Boost Release 1.57]
|
||||||
|
@@ -808,30 +808,74 @@
|
|||||||
is <a href="../../../../../utility/CopyConstructible.html" target="_top"><code class="computeroutput"><span class="identifier">CopyConstructible</span></code></a> and <code class="computeroutput"><span class="identifier">CopyAssignable</span></code>.
|
is <a href="../../../../../utility/CopyConstructible.html" target="_top"><code class="computeroutput"><span class="identifier">CopyConstructible</span></code></a> and <code class="computeroutput"><span class="identifier">CopyAssignable</span></code>.
|
||||||
</li>
|
</li>
|
||||||
<li class="listitem">
|
<li class="listitem">
|
||||||
|
<p class="simpara">
|
||||||
<span class="bold"><strong>Effects:</strong></span>
|
<span class="bold"><strong>Effects:</strong></span>
|
||||||
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: circle; ">
|
</p>
|
||||||
<li class="listitem">
|
<div class="informaltable"><table class="table">
|
||||||
If <code class="computeroutput"><span class="special">!*</span><span class="keyword">this</span>
|
<colgroup>
|
||||||
<span class="special">&&</span> <span class="special">!</span><span class="identifier">rhs</span></code> no effect, otherwise
|
<col>
|
||||||
</li>
|
<col>
|
||||||
<li class="listitem">
|
<col>
|
||||||
if <code class="computeroutput"><span class="keyword">bool</span><span class="special">(*</span><span class="keyword">this</span><span class="special">)</span>
|
</colgroup>
|
||||||
<span class="special">&&</span> <span class="special">!</span><span class="identifier">rhs</span></code>, destroys the contained value
|
<thead><tr>
|
||||||
by calling <code class="computeroutput"><span class="identifier">val</span><span class="special">-></span><span class="identifier">T</span><span class="special">::~</span><span class="identifier">T</span><span class="special">()</span></code>, otherwise
|
<th>
|
||||||
</li>
|
</th>
|
||||||
<li class="listitem">
|
<th>
|
||||||
if <code class="computeroutput"><span class="special">!*</span><span class="keyword">this</span>
|
<p>
|
||||||
<span class="special">&&</span> <span class="keyword">bool</span><span class="special">(</span><span class="identifier">rhs</span><span class="special">)</span></code>, initializes the contained value
|
<code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code>
|
||||||
as if direct-initializing an object of type <code class="computeroutput"><span class="identifier">T</span></code>
|
contains a value
|
||||||
with <code class="computeroutput"><span class="special">*</span><span class="identifier">rhs</span></code>,
|
</p>
|
||||||
otherwise
|
</th>
|
||||||
</li>
|
<th>
|
||||||
<li class="listitem">
|
<p>
|
||||||
(if <code class="computeroutput"><span class="keyword">bool</span><span class="special">(*</span><span class="keyword">this</span><span class="special">)</span>
|
<code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code>
|
||||||
<span class="special">&&</span> <span class="keyword">bool</span><span class="special">(</span><span class="identifier">rhs</span><span class="special">)</span></code>) assigns <code class="computeroutput"><span class="special">*</span><span class="identifier">rhs</span></code> to the contained value.
|
does not contain a value
|
||||||
</li>
|
</p>
|
||||||
</ul></div>
|
</th>
|
||||||
</li>
|
</tr></thead>
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<p>
|
||||||
|
<code class="computeroutput"><span class="identifier">rhs</span></code> contains
|
||||||
|
a value
|
||||||
|
</p>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<p>
|
||||||
|
assigns <code class="computeroutput"><span class="special">*</span><span class="identifier">rhs</span></code>
|
||||||
|
to the contained value
|
||||||
|
</p>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<p>
|
||||||
|
initializes the contained value as if direct-initializing an
|
||||||
|
object of type <code class="computeroutput"><span class="identifier">T</span></code>
|
||||||
|
with <code class="computeroutput"><span class="special">*</span><span class="identifier">rhs</span></code>
|
||||||
|
</p>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<p>
|
||||||
|
<code class="computeroutput"><span class="identifier">rhs</span></code> does not
|
||||||
|
contain a value
|
||||||
|
</p>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<p>
|
||||||
|
destroys the contained value by calling <code class="computeroutput"><span class="identifier">val</span><span class="special">-></span><span class="identifier">T</span><span class="special">::~</span><span class="identifier">T</span><span class="special">()</span></code>
|
||||||
|
</p>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<p>
|
||||||
|
no effect
|
||||||
|
</p>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table></div>
|
||||||
|
</li>
|
||||||
<li class="listitem">
|
<li class="listitem">
|
||||||
<span class="bold"><strong>Returns:</strong></span> <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code>;
|
<span class="bold"><strong>Returns:</strong></span> <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code>;
|
||||||
</li>
|
</li>
|
||||||
@@ -919,30 +963,73 @@
|
|||||||
and <code class="computeroutput"><span class="identifier">MoveAssignable</span></code>.
|
and <code class="computeroutput"><span class="identifier">MoveAssignable</span></code>.
|
||||||
</li>
|
</li>
|
||||||
<li class="listitem">
|
<li class="listitem">
|
||||||
|
<p class="simpara">
|
||||||
<span class="bold"><strong>Effects:</strong></span>
|
<span class="bold"><strong>Effects:</strong></span>
|
||||||
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: circle; ">
|
</p>
|
||||||
<li class="listitem">
|
<div class="informaltable"><table class="table">
|
||||||
If <code class="computeroutput"><span class="special">!*</span><span class="keyword">this</span>
|
<colgroup>
|
||||||
<span class="special">&&</span> <span class="special">!</span><span class="identifier">rhs</span></code> no effect, otherwise
|
<col>
|
||||||
</li>
|
<col>
|
||||||
<li class="listitem">
|
<col>
|
||||||
if <code class="computeroutput"><span class="keyword">bool</span><span class="special">(*</span><span class="keyword">this</span><span class="special">)</span>
|
</colgroup>
|
||||||
<span class="special">&&</span> <span class="special">!</span><span class="identifier">rhs</span></code>, destroys the contained value
|
<thead><tr>
|
||||||
by calling <code class="computeroutput"><span class="identifier">val</span><span class="special">-></span><span class="identifier">T</span><span class="special">::~</span><span class="identifier">T</span><span class="special">()</span></code>, otherwise
|
<th>
|
||||||
</li>
|
</th>
|
||||||
<li class="listitem">
|
<th>
|
||||||
if <code class="computeroutput"><span class="special">!*</span><span class="keyword">this</span>
|
<p>
|
||||||
<span class="special">&&</span> <span class="keyword">bool</span><span class="special">(</span><span class="identifier">rhs</span><span class="special">)</span></code>, initializes the contained value
|
<code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code>
|
||||||
as if direct-initializing an object of type <code class="computeroutput"><span class="identifier">T</span></code>
|
contains a value
|
||||||
with <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">move</span><span class="special">(*</span><span class="identifier">rhs</span><span class="special">)</span></code>,
|
</p>
|
||||||
otherwise
|
</th>
|
||||||
</li>
|
<th>
|
||||||
<li class="listitem">
|
<p>
|
||||||
(if <code class="computeroutput"><span class="keyword">bool</span><span class="special">(*</span><span class="keyword">this</span><span class="special">)</span>
|
<code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code>
|
||||||
<span class="special">&&</span> <span class="keyword">bool</span><span class="special">(</span><span class="identifier">rhs</span><span class="special">)</span></code>) assigns <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">move</span><span class="special">(*</span><span class="identifier">rhs</span><span class="special">)</span></code> to the contained value.
|
does not contain a value
|
||||||
</li>
|
</p>
|
||||||
</ul></div>
|
</th>
|
||||||
</li>
|
</tr></thead>
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<p>
|
||||||
|
<code class="computeroutput"><span class="identifier">rhs</span></code> contains
|
||||||
|
a value
|
||||||
|
</p>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<p>
|
||||||
|
assigns <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">move</span><span class="special">(*</span><span class="identifier">rhs</span><span class="special">)</span></code> to the contained value
|
||||||
|
</p>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<p>
|
||||||
|
initializes the contained value as if direct-initializing an
|
||||||
|
object of type <code class="computeroutput"><span class="identifier">T</span></code>
|
||||||
|
with <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">move</span><span class="special">(*</span><span class="identifier">rhs</span><span class="special">)</span></code>
|
||||||
|
</p>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<p>
|
||||||
|
<code class="computeroutput"><span class="identifier">rhs</span></code> does not
|
||||||
|
contain a value
|
||||||
|
</p>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<p>
|
||||||
|
destroys the contained value by calling <code class="computeroutput"><span class="identifier">val</span><span class="special">-></span><span class="identifier">T</span><span class="special">::~</span><span class="identifier">T</span><span class="special">()</span></code>
|
||||||
|
</p>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<p>
|
||||||
|
no effect
|
||||||
|
</p>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table></div>
|
||||||
|
</li>
|
||||||
<li class="listitem">
|
<li class="listitem">
|
||||||
<span class="bold"><strong>Returns:</strong></span> <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code>;
|
<span class="bold"><strong>Returns:</strong></span> <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code>;
|
||||||
</li>
|
</li>
|
||||||
@@ -997,40 +1084,88 @@
|
|||||||
</p></blockquote></div>
|
</p></blockquote></div>
|
||||||
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
|
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
|
||||||
<li class="listitem">
|
<li class="listitem">
|
||||||
<span class="bold"><strong>Effect:</strong></span> Assigns another convertible
|
<p class="simpara">
|
||||||
optional to an optional.
|
<span class="bold"><strong>Effect:</strong></span>
|
||||||
|
</p>
|
||||||
|
<div class="informaltable"><table class="table">
|
||||||
|
<colgroup>
|
||||||
|
<col>
|
||||||
|
<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>
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<p>
|
||||||
|
<code class="computeroutput"><span class="identifier">rhs</span></code> contains
|
||||||
|
a value
|
||||||
|
</p>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<p>
|
||||||
|
assigns <code class="computeroutput"><span class="special">*</span><span class="identifier">rhs</span></code>
|
||||||
|
to the contained value
|
||||||
|
</p>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<p>
|
||||||
|
initializes the contained value as if direct-initializing an
|
||||||
|
object of type <code class="computeroutput"><span class="identifier">T</span></code>
|
||||||
|
with <code class="computeroutput"><span class="special">*</span><span class="identifier">rhs</span></code>
|
||||||
|
</p>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<p>
|
||||||
|
<code class="computeroutput"><span class="identifier">rhs</span></code> does not
|
||||||
|
contain a value
|
||||||
|
</p>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<p>
|
||||||
|
destroys the contained value by calling <code class="computeroutput"><span class="identifier">val</span><span class="special">-></span><span class="identifier">T</span><span class="special">::~</span><span class="identifier">T</span><span class="special">()</span></code>
|
||||||
|
</p>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<p>
|
||||||
|
no effect
|
||||||
|
</p>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table></div>
|
||||||
|
</li>
|
||||||
|
<li class="listitem">
|
||||||
|
<span class="bold"><strong>Returns:</strong></span> <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code>.
|
||||||
</li>
|
</li>
|
||||||
<li class="listitem">
|
<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> <code class="computeroutput"><span class="keyword">bool</span><span class="special">(</span><span class="identifier">rhs</span><span class="special">)</span> <span class="special">==</span> <span class="keyword">bool</span><span class="special">(*</span><span class="keyword">this</span><span class="special">)</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
|
|
||||||
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.
|
|
||||||
</li>
|
</li>
|
||||||
<li class="listitem">
|
<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 <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="bold"><strong>Exception Safety:</strong></span> If any exception is
|
||||||
</li>
|
thrown, the result of the expression <code class="computeroutput"><span class="keyword">bool</span><span class="special">(*</span><span class="keyword">this</span><span class="special">)</span></code> remains unchanged. If an exception is
|
||||||
<li class="listitem">
|
thrown during the call to <code class="computeroutput"><span class="identifier">T</span></code>'s
|
||||||
<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,
|
constructor, no effect. If an exception is thrown during the call to
|
||||||
<code class="computeroutput"><span class="identifier">T</span></code>'s <span class="emphasis"><em>assignment
|
<code class="computeroutput"><span class="identifier">T</span></code>'s assignment, the state
|
||||||
operator</em></span> (from <code class="computeroutput"><span class="identifier">U</span></code>)
|
of its contained value is as defined by the exception safety guarantee
|
||||||
is used. If <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code>
|
of <code class="computeroutput"><span class="identifier">T</span></code>'s copy assignment.
|
||||||
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>destructor</em></span> is called. If <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> is initially uninitialized but rhs
|
|
||||||
is initialized, <code class="computeroutput"><span class="identifier">T</span></code>'s
|
|
||||||
<span class="emphasis"><em>converting constructor</em></span> (from <code class="computeroutput"><span class="identifier">U</span></code>)
|
|
||||||
is called.
|
|
||||||
</li>
|
|
||||||
<li class="listitem">
|
|
||||||
<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
|
|
||||||
as far as optional is concerned (it is up to <code class="computeroutput"><span class="identifier">T</span></code>'s
|
|
||||||
<code class="computeroutput"><span class="keyword">operator</span><span class="special">=()</span></code>).
|
|
||||||
If <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code>
|
|
||||||
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.
|
|
||||||
</li>
|
</li>
|
||||||
<li class="listitem">
|
<li class="listitem">
|
||||||
<span class="bold"><strong>Example:</strong></span>
|
<span class="bold"><strong>Example:</strong></span>
|
||||||
@@ -1053,36 +1188,87 @@
|
|||||||
</p></blockquote></div>
|
</p></blockquote></div>
|
||||||
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
|
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
|
||||||
<li class="listitem">
|
<li class="listitem">
|
||||||
<span class="bold"><strong>Effect:</strong></span> Move-assigns another convertible
|
<p class="simpara">
|
||||||
optional to an optional.
|
<span class="bold"><strong>Effect:</strong></span>
|
||||||
|
</p>
|
||||||
|
<div class="informaltable"><table class="table">
|
||||||
|
<colgroup>
|
||||||
|
<col>
|
||||||
|
<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>
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<p>
|
||||||
|
<code class="computeroutput"><span class="identifier">rhs</span></code> contains
|
||||||
|
a value
|
||||||
|
</p>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<p>
|
||||||
|
assigns <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">move</span><span class="special">(*</span><span class="identifier">rhs</span><span class="special">)</span></code> to the contained value
|
||||||
|
</p>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<p>
|
||||||
|
initializes the contained value as if direct-initializing an
|
||||||
|
object of type <code class="computeroutput"><span class="identifier">T</span></code>
|
||||||
|
with <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">move</span><span class="special">(*</span><span class="identifier">rhs</span><span class="special">)</span></code>
|
||||||
|
</p>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<p>
|
||||||
|
<code class="computeroutput"><span class="identifier">rhs</span></code> does not
|
||||||
|
contain a value
|
||||||
|
</p>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<p>
|
||||||
|
destroys the contained value by calling <code class="computeroutput"><span class="identifier">val</span><span class="special">-></span><span class="identifier">T</span><span class="special">::~</span><span class="identifier">T</span><span class="special">()</span></code>
|
||||||
|
</p>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<p>
|
||||||
|
no effect
|
||||||
|
</p>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table></div>
|
||||||
|
</li>
|
||||||
|
<li class="listitem">
|
||||||
|
<span class="bold"><strong>Returns:</strong></span> <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code>.
|
||||||
</li>
|
</li>
|
||||||
<li class="listitem">
|
<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> <code class="computeroutput"><span class="keyword">bool</span><span class="special">(</span><span class="identifier">rhs</span><span class="special">)</span> <span class="special">==</span> <span class="keyword">bool</span><span class="special">(*</span><span class="keyword">this</span><span class="special">)</span></code>.
|
||||||
is initialized, <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code>
|
|
||||||
is initialized and its value is moved from 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.
|
|
||||||
</li>
|
</li>
|
||||||
<li class="listitem">
|
<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="special">&&</span> <span class="special">)</span></code>
|
<span class="bold"><strong>Exception Safety:</strong></span> If any exception is
|
||||||
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><span class="special">&&</span>
|
thrown, the result of the expression <code class="computeroutput"><span class="keyword">bool</span><span class="special">(*</span><span class="keyword">this</span><span class="special">)</span></code> remains unchanged. If an exception is
|
||||||
<span class="special">)</span></code> throws.
|
thrown during the call to <code class="computeroutput"><span class="identifier">T</span></code>'s
|
||||||
</li>
|
constructor, no effect. If an exception is thrown during the call to
|
||||||
<li class="listitem">
|
<code class="computeroutput"><span class="identifier">T</span></code>'s assignment, the state
|
||||||
<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>
|
of its contained value is as defined by the exception safety guarantee
|
||||||
are initially initialized, <code class="computeroutput"><span class="identifier">T</span></code>'s
|
of <code class="computeroutput"><span class="identifier">T</span></code>'s copy assignment.
|
||||||
<span class="emphasis"><em>assignment operator</em></span> (from <code class="computeroutput"><span class="identifier">U</span><span class="special">&&</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, <code class="computeroutput"><span class="identifier">T</span></code>'s
|
|
||||||
<span class="emphasis"><em>destructor</em></span> 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>converting constructor</em></span> (from <code class="computeroutput"><span class="identifier">U</span><span class="special">&&</span></code>) is called.
|
|
||||||
</li>
|
|
||||||
<li class="listitem">
|
|
||||||
<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
|
|
||||||
as far as optional is concerned (it is up to <code class="computeroutput"><span class="identifier">T</span></code>'s
|
|
||||||
<code class="computeroutput"><span class="keyword">operator</span><span class="special">=()</span></code>).
|
|
||||||
If <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code>
|
|
||||||
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.
|
|
||||||
</li>
|
</li>
|
||||||
<li class="listitem">
|
<li class="listitem">
|
||||||
<span class="bold"><strong>Example:</strong></span>
|
<span class="bold"><strong>Example:</strong></span>
|
||||||
@@ -2019,35 +2205,81 @@
|
|||||||
<span class="bold"><strong>Requires:</strong></span> Lvalues of type <code class="computeroutput"><span class="identifier">T</span></code> shall be swappable and <code class="computeroutput"><span class="identifier">T</span></code> shall be <code class="computeroutput"><span class="identifier">MoveConstructible</span></code>.
|
<span class="bold"><strong>Requires:</strong></span> Lvalues of type <code class="computeroutput"><span class="identifier">T</span></code> shall be swappable and <code class="computeroutput"><span class="identifier">T</span></code> shall be <code class="computeroutput"><span class="identifier">MoveConstructible</span></code>.
|
||||||
</li>
|
</li>
|
||||||
<li class="listitem">
|
<li class="listitem">
|
||||||
|
<p class="simpara">
|
||||||
<span class="bold"><strong>Effects:</strong></span>
|
<span class="bold"><strong>Effects:</strong></span>
|
||||||
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: circle; ">
|
</p>
|
||||||
<li class="listitem">
|
<div class="informaltable"><table class="table">
|
||||||
If <code class="computeroutput"><span class="special">!*</span><span class="keyword">this</span>
|
<colgroup>
|
||||||
<span class="special">&&</span> <span class="special">!</span><span class="identifier">rhs</span></code>, no effect, otherwise
|
<col>
|
||||||
</li>
|
<col>
|
||||||
<li class="listitem">
|
<col>
|
||||||
if <code class="computeroutput"><span class="keyword">bool</span><span class="special">(*</span><span class="keyword">this</span><span class="special">)</span>
|
</colgroup>
|
||||||
<span class="special">&&</span> <span class="special">!</span><span class="identifier">rhs</span></code>, initializes the contained
|
<thead><tr>
|
||||||
value of <code class="computeroutput"><span class="identifier">rhs</span></code> as
|
<th>
|
||||||
if direct-initializing an object of type <code class="computeroutput"><span class="identifier">T</span></code>
|
</th>
|
||||||
with the expression <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">move</span><span class="special">(*(*</span><span class="keyword">this</span><span class="special">))</span></code>, followed by <code class="computeroutput"><span class="identifier">val</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="special">*</span><span class="keyword">this</span></code> does not contain a value and
|
<th>
|
||||||
<code class="computeroutput"><span class="identifier">rhs</span></code> contains a
|
<p>
|
||||||
value, otherwise
|
<code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code>
|
||||||
</li>
|
contains a value
|
||||||
<li class="listitem">
|
</p>
|
||||||
if <code class="computeroutput"><span class="special">!*</span><span class="keyword">this</span>
|
</th>
|
||||||
<span class="special">&&</span> <span class="keyword">bool</span><span class="special">(</span><span class="identifier">rhs</span><span class="special">)</span></code>, initializes the contained value
|
<th>
|
||||||
of <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code>
|
<p>
|
||||||
as if direct-initializing an object of type <code class="computeroutput"><span class="identifier">T</span></code>
|
<code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code>
|
||||||
with the expression <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">move</span><span class="special">(*</span><span class="identifier">rhs</span><span class="special">)</span></code>, followed by <code class="computeroutput"><span class="identifier">rhs</span><span class="special">.</span><span class="identifier">val</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="special">*</span><span class="keyword">this</span></code> contains a value and <code class="computeroutput"><span class="identifier">rhs</span></code> does not contain a value,
|
does not contain a value
|
||||||
otherwise
|
</p>
|
||||||
</li>
|
</th>
|
||||||
<li class="listitem">
|
</tr></thead>
|
||||||
(if <code class="computeroutput"><span class="keyword">bool</span><span class="special">(*</span><span class="keyword">this</span><span class="special">)</span>
|
<tbody>
|
||||||
<span class="special">&&</span> <span class="keyword">bool</span><span class="special">(</span><span class="identifier">rhs</span><span class="special">)</span></code>) calls <code class="computeroutput"><span class="identifier">swap</span><span class="special">(*(*</span><span class="keyword">this</span><span class="special">),</span> <span class="special">*</span><span class="identifier">rhs</span><span class="special">)</span></code>.
|
<tr>
|
||||||
</li>
|
<td>
|
||||||
</ul></div>
|
<p>
|
||||||
</li>
|
<code class="computeroutput"><span class="identifier">rhs</span></code> contains
|
||||||
|
a value
|
||||||
|
</p>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<p>
|
||||||
|
calls <code class="computeroutput"><span class="identifier">swap</span><span class="special">(*(*</span><span class="keyword">this</span><span class="special">),</span> <span class="special">*</span><span class="identifier">rhs</span><span class="special">)</span></code>
|
||||||
|
</p>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<p>
|
||||||
|
initializes the contained value of <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> as if direct-initializing
|
||||||
|
an object of type <code class="computeroutput"><span class="identifier">T</span></code>
|
||||||
|
with the expression <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">move</span><span class="special">(*</span><span class="identifier">rhs</span><span class="special">)</span></code>, followed by <code class="computeroutput"><span class="identifier">rhs</span><span class="special">.</span><span class="identifier">val</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="special">*</span><span class="keyword">this</span></code>
|
||||||
|
contains a value and <code class="computeroutput"><span class="identifier">rhs</span></code>
|
||||||
|
does not contain a value
|
||||||
|
</p>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<p>
|
||||||
|
<code class="computeroutput"><span class="identifier">rhs</span></code> does not
|
||||||
|
contain a value
|
||||||
|
</p>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<p>
|
||||||
|
initializes the contained value of <code class="computeroutput"><span class="identifier">rhs</span></code>
|
||||||
|
as if direct-initializing an object of type <code class="computeroutput"><span class="identifier">T</span></code>
|
||||||
|
with the expression <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">move</span><span class="special">(*(*</span><span class="keyword">this</span><span class="special">))</span></code>, followed by <code class="computeroutput"><span class="identifier">val</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="special">*</span><span class="keyword">this</span></code>
|
||||||
|
does not contain a value and <code class="computeroutput"><span class="identifier">rhs</span></code>
|
||||||
|
contains a value
|
||||||
|
</p>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<p>
|
||||||
|
no effect
|
||||||
|
</p>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table></div>
|
||||||
|
</li>
|
||||||
<li class="listitem">
|
<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.
|
||||||
|
@@ -52,6 +52,10 @@
|
|||||||
This can be used to work around <a href="https://svn.boost.org/trac/boost/ticket/10399" target="_top">Trac
|
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>
|
||||||
|
<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>
|
||||||
|
is not assignable or convertible to <code class="computeroutput"><span class="identifier">T</span></code>.
|
||||||
|
</li>
|
||||||
</ul></div>
|
</ul></div>
|
||||||
<h4>
|
<h4>
|
||||||
<a name="boost_optional.relnotes.h1"></a>
|
<a name="boost_optional.relnotes.h1"></a>
|
||||||
|
@@ -138,7 +138,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||||||
<td align="left"><p><small>Last revised: January 21, 2015 at 13:59:23 GMT</small></p></td>
|
<td align="left"><p><small>Last revised: March 06, 2015 at 18:13:34 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>
|
||||||
|
@@ -188,7 +188,7 @@ struct types_when_is_ref
|
|||||||
template <class To, class From>
|
template <class To, class From>
|
||||||
void prevent_binding_rvalue_ref_to_optional_lvalue_ref()
|
void prevent_binding_rvalue_ref_to_optional_lvalue_ref()
|
||||||
{
|
{
|
||||||
#ifndef BOOST_OPTIONAL_ALLOW_BINDING_TO_RVALUES
|
#ifndef BOOST_OPTIONAL_CONFIG_ALLOW_BINDING_TO_RVALUES
|
||||||
BOOST_STATIC_ASSERT_MSG(
|
BOOST_STATIC_ASSERT_MSG(
|
||||||
!boost::is_lvalue_reference<To>::value || !boost::is_rvalue_reference<From>::value,
|
!boost::is_lvalue_reference<To>::value || !boost::is_rvalue_reference<From>::value,
|
||||||
"binding rvalue references to optional lvalue references is disallowed");
|
"binding rvalue references to optional lvalue references is disallowed");
|
||||||
@@ -371,13 +371,22 @@ class optional_base : public optional_tag
|
|||||||
if (is_initialized())
|
if (is_initialized())
|
||||||
{
|
{
|
||||||
if ( rhs.is_initialized() )
|
if ( rhs.is_initialized() )
|
||||||
assign_value(static_cast<value_type>(rhs.get()), is_reference_predicate() );
|
#ifndef BOOST_OPTIONAL_CONFIG_RESTORE_ASSIGNMENT_OF_NONCONVERTIBLE_TYPES
|
||||||
|
assign_value(rhs.get(), is_reference_predicate() );
|
||||||
|
#else
|
||||||
|
assign_value(static_cast<value_type>(rhs.get()), is_reference_predicate() );
|
||||||
|
#endif
|
||||||
|
|
||||||
else destroy();
|
else destroy();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if ( rhs.is_initialized() )
|
if ( rhs.is_initialized() )
|
||||||
|
#ifndef BOOST_OPTIONAL_CONFIG_RESTORE_ASSIGNMENT_OF_NONCONVERTIBLE_TYPES
|
||||||
|
construct(rhs.get());
|
||||||
|
#else
|
||||||
construct(static_cast<value_type>(rhs.get()));
|
construct(static_cast<value_type>(rhs.get()));
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -56,5 +56,6 @@ import testing ;
|
|||||||
[ compile-fail optional_test_fail_explicit_convert_in_value_or.cpp ]
|
[ compile-fail optional_test_fail_explicit_convert_in_value_or.cpp ]
|
||||||
[ compile-fail optional_test_fail_explicit_convert_in_value_or_call.cpp ]
|
[ compile-fail optional_test_fail_explicit_convert_in_value_or_call.cpp ]
|
||||||
[ compile-fail optional_test_fail_io_without_io.cpp ]
|
[ compile-fail optional_test_fail_io_without_io.cpp ]
|
||||||
|
[ compile-fail optional_test_fail_convert_assign_of_enums.cpp ]
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
27
test/optional_test_fail_convert_assign_of_enums.cpp
Normal file
27
test/optional_test_fail_convert_assign_of_enums.cpp
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
// Copyright (C) 2015, Andrzej Krzemienski.
|
||||||
|
//
|
||||||
|
// 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:
|
||||||
|
// akrzemi1@gmail.com
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
#include "boost/optional.hpp"
|
||||||
|
|
||||||
|
// THIS TEST SHOULD FAIL TO COMPILE
|
||||||
|
|
||||||
|
enum E1 {e1};
|
||||||
|
enum E2 {e2};
|
||||||
|
|
||||||
|
void test_converitng_assignment_of_different_enums()
|
||||||
|
{
|
||||||
|
boost::optional<E2> o2(e2);
|
||||||
|
boost::optional<E1> o1;
|
||||||
|
o1 = o2;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main() {}
|
Reference in New Issue
Block a user