mirror of
https://github.com/boostorg/optional.git
synced 2025-07-21 16:22:09 +02:00
Cleaner handling of explicit U to T conversions
This commit is contained in:
@ -326,7 +326,7 @@ __SPACE__
|
|||||||
value is another reference to the same object referenced by `*rhs`; else
|
value is another reference to the same object referenced by `*rhs`; else
|
||||||
`*this` is uninitialized.
|
`*this` is uninitialized.
|
||||||
* [*Throws:] Nothing.
|
* [*Throws:] Nothing.
|
||||||
* [*Notes:] If `rhs` is initialized, both `*this` and `*rhs` will reefer to the
|
* [*Notes:] If `rhs` is initialized, both `*this` and `*rhs` will refer to the
|
||||||
same object (they alias).
|
same object (they alias).
|
||||||
* [*Example:]
|
* [*Example:]
|
||||||
``
|
``
|
||||||
@ -360,7 +360,8 @@ __SPACE__
|
|||||||
* [*Postconditions:] If `rhs` is initialized, `*this` is initialized and
|
* [*Postconditions:] If `rhs` is initialized, `*this` is initialized and
|
||||||
its value is move constructed from `rhs`; else `*this` is uninitialized.
|
its value is move constructed from `rhs`; else `*this` is uninitialized.
|
||||||
* [*Throws:] Whatever `T::T( T&& )` throws.
|
* [*Throws:] Whatever `T::T( T&& )` throws.
|
||||||
* [*Notes:] If `rhs` is initialized, `T::T( T && )` is called. The expression inside `noexcept` is equivalent to `is_nothrow_move_constructible<T>::value`.
|
* [*Remarks:] The expression inside `noexcept` is equivalent to `is_nothrow_move_constructible<T>::value`.
|
||||||
|
* [*Notes:] If `rhs` is initialized, `T::T( T && )` is called.
|
||||||
* [*Exception Safety:] Exceptions can only be thrown during
|
* [*Exception Safety:] Exceptions can only be thrown during
|
||||||
`T::T( T&& );` in that case, `rhs` remains initialized and the value of `*rhs` is determined by exception safety of `T::T(T&&)`.
|
`T::T( T&& );` in that case, `rhs` remains initialized and the value of `*rhs` is determined by exception safety of `T::T(T&&)`.
|
||||||
* [*Example:]
|
* [*Example:]
|
||||||
@ -390,7 +391,7 @@ __SPACE__
|
|||||||
value is another reference to the same object referenced by `*rhs`; else
|
value is another reference to the same object referenced by `*rhs`; else
|
||||||
`*this` is uninitialized.
|
`*this` is uninitialized.
|
||||||
* [*Throws:] Nothing.
|
* [*Throws:] Nothing.
|
||||||
* [*Notes:] If `rhs` is initialized, both `*this` and `*rhs` will reefer to the
|
* [*Notes:] If `rhs` is initialized, both `*this` and `*rhs` will refer to the
|
||||||
same object (they alias).
|
same object (they alias).
|
||||||
* [*Example:]
|
* [*Example:]
|
||||||
``
|
``
|
||||||
@ -663,11 +664,12 @@ __SPACE__
|
|||||||
* [*Effect:] Move-assigns another `optional` to an `optional`.
|
* [*Effect:] Move-assigns another `optional` to an `optional`.
|
||||||
* [*Postconditions:] If `rhs` is initialized, `*this` is initialized and
|
* [*Postconditions:] If `rhs` is initialized, `*this` is initialized and
|
||||||
its value is moved from `*rhs`, `rhs` remains initialized; else `*this` is uninitialized.
|
its value is moved from `*rhs`, `rhs` remains initialized; else `*this` is uninitialized.
|
||||||
* [*Throws:] Whatever `T::operator( T&& )` or `T::T( T && )` throws.
|
* [*Throws:] Whatever `T::operator( T&& )` or `T::T( T && )` throws.
|
||||||
|
* [*Remarks:] The expression inside `noexcept` is equivalent to `is_nothrow_move_constructible<T>::value && is_nothrow_move_assignable<T>::value`.
|
||||||
* [*Notes:] If both `*this` and `rhs` are initially initialized, `T`'s
|
* [*Notes:] If both `*this` and `rhs` are initially initialized, `T`'s
|
||||||
['move assignment operator] is used. If `*this` is initially initialized but `rhs` is
|
['move assignment operator] is used. If `*this` is initially initialized but `rhs` is
|
||||||
uninitialized, `T`'s [destructor] is called. If `*this` is initially uninitialized
|
uninitialized, `T`'s [destructor] is called. If `*this` is initially uninitialized
|
||||||
but `rhs` is initialized, `T`'s ['move constructor] is called. The expression inside `noexcept` is equivalent to `is_nothrow_move_constructible<T>::value && is_nothrow_move_assignable<T>::value`.
|
but `rhs` is initialized, `T`'s ['move constructor] is called.
|
||||||
* [*Exception Safety:] In the event of an exception, the initialization state of
|
* [*Exception Safety:] In the event of an exception, the initialization state of
|
||||||
`*this` is unchanged and its value unspecified as far as optional is concerned
|
`*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
|
(it is up to `T`'s `operator=()`). If `*this` is initially uninitialized and
|
||||||
@ -932,8 +934,7 @@ __SPACE__
|
|||||||
[: `template<class U> T optional<T>::value_or(U && v) const& ;`]
|
[: `template<class U> T optional<T>::value_or(U && v) const& ;`]
|
||||||
|
|
||||||
* [*Requires:] `T` is __COPY_CONSTRUCTIBLE__ and `U &&` is convertible to `T`.
|
* [*Requires:] `T` is __COPY_CONSTRUCTIBLE__ and `U &&` is convertible to `T`.
|
||||||
* [*Returns:] `bool(*this) ? **this : static_cast<T>(std::forward<U>(v))`.
|
* [*Effects:] `if (*this) return **this; else return std::forward<U>(v);`.
|
||||||
* [*Throws:] Any exception thrown by the selected constructor of `T`.
|
|
||||||
* [*Notes:] On compilers that do not support ref-qualifiers on member functions this overload is replaced with the `const`-qualified member function. On compilers without rvalue reference support the type of `v` becomes `U const&`.
|
* [*Notes:] On compilers that do not support ref-qualifiers on member functions this overload is replaced with the `const`-qualified member function. On compilers without rvalue reference support the type of `v` becomes `U const&`.
|
||||||
|
|
||||||
__SPACE__
|
__SPACE__
|
||||||
@ -943,8 +944,7 @@ __SPACE__
|
|||||||
[: `template<class U> T optional<T>::value_or(U && v) && ;`]
|
[: `template<class U> T optional<T>::value_or(U && v) && ;`]
|
||||||
|
|
||||||
* [*Requires:] `T` is __MOVE_CONSTRUCTIBLE__ and `U &&` is convertible to `T`.
|
* [*Requires:] `T` is __MOVE_CONSTRUCTIBLE__ and `U &&` is convertible to `T`.
|
||||||
* [*Returns:] `bool(*this) ? std::move(**this) : static_cast<T>(std::forward<U>(v))`.
|
* [*Effects:] `if (*this) return std::move(**this); else return std::forward<U>(v);`.
|
||||||
* [*Throws:] Any exception thrown by the selected constructor of `T`.
|
|
||||||
* [*Notes:] On compilers that do not support ref-qualifiers on member functions this overload is not present.
|
* [*Notes:] On compilers that do not support ref-qualifiers on member functions this overload is not present.
|
||||||
|
|
||||||
__SPACE__
|
__SPACE__
|
||||||
@ -954,9 +954,8 @@ __SPACE__
|
|||||||
[: `template<class F> T optional<T>::value_or_eval(F f) const& ;`]
|
[: `template<class F> T optional<T>::value_or_eval(F f) const& ;`]
|
||||||
|
|
||||||
* [*Requires:] `T` is __COPY_CONSTRUCTIBLE__ and `F` models a __SGI_GENERATOR__ whose result type is convertible to `T`.
|
* [*Requires:] `T` is __COPY_CONSTRUCTIBLE__ and `F` models a __SGI_GENERATOR__ whose result type is convertible to `T`.
|
||||||
* [*Returns:] `bool(*this) ? **this : static_cast<T>(f())`.
|
* [*Effects:] `if (*this) return **this; else return f();`.
|
||||||
* [*Throws:] Any exception thrown by the selected constructor of `T` or by `f`.
|
* [*Notes:] On compilers that do not support ref-qualifiers on member functions this overload is replaced with the `const`-qualified member function.
|
||||||
* [*Notes:] Function `f` is only evaluated if `bool(*this) == false`. On compilers that do not support ref-qualifiers on member functions this overload is replaced with the `const`-qualified member function.
|
|
||||||
* [*Example:]
|
* [*Example:]
|
||||||
``
|
``
|
||||||
int complain_and_0()
|
int complain_and_0()
|
||||||
@ -982,9 +981,8 @@ __SPACE__
|
|||||||
[: `template<class F> T optional<T>::value_or_eval(F f) && ;`]
|
[: `template<class F> T optional<T>::value_or_eval(F f) && ;`]
|
||||||
|
|
||||||
* [*Requires:] `T` is __MOVE_CONSTRUCTIBLE__ and `F` models a __SGI_GENERATOR__ whose result type is convertible to `T`.
|
* [*Requires:] `T` is __MOVE_CONSTRUCTIBLE__ and `F` models a __SGI_GENERATOR__ whose result type is convertible to `T`.
|
||||||
* [*Returns:] `bool(*this) ? std::move(**this) : static_cast<T>(f())`.
|
* [*Effects:] `if (*this) return std::move(**this); else return f();`.
|
||||||
* [*Throws:] Any exception thrown by the selected constructor of `T` or by `f`.
|
* [*Notes:] On compilers that do not support ref-qualifiers on member functions this overload is not present.
|
||||||
* [*Notes:] Function `f` is only evaluated if `bool(*this) == false`. On compilers that do not support ref-qualifiers on member functions this overload is not present.
|
|
||||||
|
|
||||||
__SPACE__
|
__SPACE__
|
||||||
|
|
||||||
|
@ -352,7 +352,7 @@
|
|||||||
<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 refer to the same object (they alias).
|
||||||
</li>
|
</li>
|
||||||
<li class="listitem">
|
<li class="listitem">
|
||||||
<span class="bold"><strong>Example:</strong></span>
|
<span class="bold"><strong>Example:</strong></span>
|
||||||
@ -402,12 +402,13 @@
|
|||||||
<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="special">&&</span> <span class="special">)</span></code>
|
<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="special">&&</span> <span class="special">)</span></code>
|
||||||
throws.
|
throws.
|
||||||
</li>
|
</li>
|
||||||
|
<li class="listitem">
|
||||||
|
<span class="bold"><strong>Remarks:</strong></span> The expression inside <code class="computeroutput"><span class="keyword">noexcept</span></code> is equivalent to <code class="computeroutput"><span class="identifier">is_nothrow_move_constructible</span><span class="special"><</span><span class="identifier">T</span><span class="special">>::</span><span class="identifier">value</span></code>.
|
||||||
|
</li>
|
||||||
<li class="listitem">
|
<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, <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="special">&&</span>
|
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="special">&&</span>
|
||||||
<span class="special">)</span></code> is called. The expression inside
|
<span class="special">)</span></code> is called.
|
||||||
<code class="computeroutput"><span class="keyword">noexcept</span></code> is equivalent to
|
|
||||||
<code class="computeroutput"><span class="identifier">is_nothrow_move_constructible</span><span class="special"><</span><span class="identifier">T</span><span class="special">>::</span><span class="identifier">value</span></code>.
|
|
||||||
</li>
|
</li>
|
||||||
<li class="listitem">
|
<li class="listitem">
|
||||||
<span class="bold"><strong>Exception Safety:</strong></span> Exceptions can only
|
<span class="bold"><strong>Exception Safety:</strong></span> Exceptions can only
|
||||||
@ -461,7 +462,7 @@
|
|||||||
<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 refer to the same object (they alias).
|
||||||
</li>
|
</li>
|
||||||
<li class="listitem">
|
<li class="listitem">
|
||||||
<span class="bold"><strong>Example:</strong></span>
|
<span class="bold"><strong>Example:</strong></span>
|
||||||
@ -914,6 +915,10 @@
|
|||||||
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="special">&&</span>
|
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="special">&&</span>
|
||||||
<span class="special">)</span></code> throws.
|
<span class="special">)</span></code> throws.
|
||||||
</li>
|
</li>
|
||||||
|
<li class="listitem">
|
||||||
|
<span class="bold"><strong>Remarks:</strong></span> The expression inside <code class="computeroutput"><span class="keyword">noexcept</span></code> is equivalent to <code class="computeroutput"><span class="identifier">is_nothrow_move_constructible</span><span class="special"><</span><span class="identifier">T</span><span class="special">>::</span><span class="identifier">value</span> <span class="special">&&</span>
|
||||||
|
<span class="identifier">is_nothrow_move_assignable</span><span class="special"><</span><span class="identifier">T</span><span class="special">>::</span><span class="identifier">value</span></code>.
|
||||||
|
</li>
|
||||||
<li class="listitem">
|
<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
|
||||||
@ -921,10 +926,7 @@
|
|||||||
is initially initialized but <code class="computeroutput"><span class="identifier">rhs</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
|
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>move constructor</em></span> is called. The expression inside
|
<span class="emphasis"><em>move constructor</em></span> is called.
|
||||||
<code class="computeroutput"><span class="keyword">noexcept</span></code> is equivalent to
|
|
||||||
<code class="computeroutput"><span class="identifier">is_nothrow_move_constructible</span><span class="special"><</span><span class="identifier">T</span><span class="special">>::</span><span class="identifier">value</span>
|
|
||||||
<span class="special">&&</span> <span class="identifier">is_nothrow_move_assignable</span><span class="special"><</span><span class="identifier">T</span><span class="special">>::</span><span class="identifier">value</span></code>.
|
|
||||||
</li>
|
</li>
|
||||||
<li class="listitem">
|
<li class="listitem">
|
||||||
<span class="bold"><strong>Exception Safety:</strong></span> In the event of an
|
<span class="bold"><strong>Exception Safety:</strong></span> In the event of an
|
||||||
@ -1455,11 +1457,8 @@
|
|||||||
is convertible to <code class="computeroutput"><span class="identifier">T</span></code>.
|
is convertible to <code class="computeroutput"><span class="identifier">T</span></code>.
|
||||||
</li>
|
</li>
|
||||||
<li class="listitem">
|
<li class="listitem">
|
||||||
<span class="bold"><strong>Returns:</strong></span> <code class="computeroutput"><span class="keyword">bool</span><span class="special">(*</span><span class="keyword">this</span><span class="special">)</span> <span class="special">?</span> <span class="special">**</span><span class="keyword">this</span> <span class="special">:</span> <span class="keyword">static_cast</span><span class="special"><</span><span class="identifier">T</span><span class="special">>(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">forward</span><span class="special"><</span><span class="identifier">U</span><span class="special">>(</span><span class="identifier">v</span><span class="special">))</span></code>.
|
<span class="bold"><strong>Effects:</strong></span> <code class="computeroutput"><span class="keyword">if</span>
|
||||||
</li>
|
<span class="special">(*</span><span class="keyword">this</span><span class="special">)</span> <span class="keyword">return</span> <span class="special">**</span><span class="keyword">this</span><span class="special">;</span> <span class="keyword">else</span> <span class="keyword">return</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">forward</span><span class="special"><</span><span class="identifier">U</span><span class="special">>(</span><span class="identifier">v</span><span class="special">);</span></code>.
|
||||||
<li class="listitem">
|
|
||||||
<span class="bold"><strong>Throws:</strong></span> Any exception thrown by the
|
|
||||||
selected constructor of <code class="computeroutput"><span class="identifier">T</span></code>.
|
|
||||||
</li>
|
</li>
|
||||||
<li class="listitem">
|
<li class="listitem">
|
||||||
<span class="bold"><strong>Notes:</strong></span> On compilers that do not support
|
<span class="bold"><strong>Notes:</strong></span> On compilers that do not support
|
||||||
@ -1485,11 +1484,9 @@
|
|||||||
is convertible to <code class="computeroutput"><span class="identifier">T</span></code>.
|
is convertible to <code class="computeroutput"><span class="identifier">T</span></code>.
|
||||||
</li>
|
</li>
|
||||||
<li class="listitem">
|
<li class="listitem">
|
||||||
<span class="bold"><strong>Returns:</strong></span> <code class="computeroutput"><span class="keyword">bool</span><span class="special">(*</span><span class="keyword">this</span><span class="special">)</span> <span class="special">?</span> <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> <span class="special">:</span> <span class="keyword">static_cast</span><span class="special"><</span><span class="identifier">T</span><span class="special">>(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">forward</span><span class="special"><</span><span class="identifier">U</span><span class="special">>(</span><span class="identifier">v</span><span class="special">))</span></code>.
|
<span class="bold"><strong>Effects:</strong></span> <code class="computeroutput"><span class="keyword">if</span>
|
||||||
</li>
|
<span class="special">(*</span><span class="keyword">this</span><span class="special">)</span> <span class="keyword">return</span> <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> <span class="keyword">else</span> <span class="keyword">return</span>
|
||||||
<li class="listitem">
|
<span class="identifier">std</span><span class="special">::</span><span class="identifier">forward</span><span class="special"><</span><span class="identifier">U</span><span class="special">>(</span><span class="identifier">v</span><span class="special">);</span></code>.
|
||||||
<span class="bold"><strong>Throws:</strong></span> Any exception thrown by the
|
|
||||||
selected constructor of <code class="computeroutput"><span class="identifier">T</span></code>.
|
|
||||||
</li>
|
</li>
|
||||||
<li class="listitem">
|
<li class="listitem">
|
||||||
<span class="bold"><strong>Notes:</strong></span> On compilers that do not support
|
<span class="bold"><strong>Notes:</strong></span> On compilers that do not support
|
||||||
@ -1509,16 +1506,11 @@
|
|||||||
is convertible to <code class="computeroutput"><span class="identifier">T</span></code>.
|
is convertible to <code class="computeroutput"><span class="identifier">T</span></code>.
|
||||||
</li>
|
</li>
|
||||||
<li class="listitem">
|
<li class="listitem">
|
||||||
<span class="bold"><strong>Returns:</strong></span> <code class="computeroutput"><span class="keyword">bool</span><span class="special">(*</span><span class="keyword">this</span><span class="special">)</span> <span class="special">?</span> <span class="special">**</span><span class="keyword">this</span> <span class="special">:</span> <span class="keyword">static_cast</span><span class="special"><</span><span class="identifier">T</span><span class="special">>(</span><span class="identifier">f</span><span class="special">())</span></code>.
|
<span class="bold"><strong>Effects:</strong></span> <code class="computeroutput"><span class="keyword">if</span>
|
||||||
|
<span class="special">(*</span><span class="keyword">this</span><span class="special">)</span> <span class="keyword">return</span> <span class="special">**</span><span class="keyword">this</span><span class="special">;</span> <span class="keyword">else</span> <span class="keyword">return</span> <span class="identifier">f</span><span class="special">();</span></code>.
|
||||||
</li>
|
</li>
|
||||||
<li class="listitem">
|
<li class="listitem">
|
||||||
<span class="bold"><strong>Throws:</strong></span> Any exception thrown by the
|
<span class="bold"><strong>Notes:</strong></span> On compilers that do not support
|
||||||
selected constructor of <code class="computeroutput"><span class="identifier">T</span></code>
|
|
||||||
or by <code class="computeroutput"><span class="identifier">f</span></code>.
|
|
||||||
</li>
|
|
||||||
<li class="listitem">
|
|
||||||
<span class="bold"><strong>Notes:</strong></span> Function <code class="computeroutput"><span class="identifier">f</span></code>
|
|
||||||
is only evaluated if <code class="computeroutput"><span class="keyword">bool</span><span class="special">(*</span><span class="keyword">this</span><span class="special">)</span> <span class="special">==</span> <span class="keyword">false</span></code>. On compilers that do not support
|
|
||||||
ref-qualifiers on member functions this overload is replaced with the
|
ref-qualifiers on member functions this overload is replaced with the
|
||||||
<code class="computeroutput"><span class="keyword">const</span></code>-qualified member function.
|
<code class="computeroutput"><span class="keyword">const</span></code>-qualified member function.
|
||||||
</li>
|
</li>
|
||||||
@ -1555,16 +1547,12 @@
|
|||||||
whose result type is convertible to <code class="computeroutput"><span class="identifier">T</span></code>.
|
whose result type is convertible to <code class="computeroutput"><span class="identifier">T</span></code>.
|
||||||
</li>
|
</li>
|
||||||
<li class="listitem">
|
<li class="listitem">
|
||||||
<span class="bold"><strong>Returns:</strong></span> <code class="computeroutput"><span class="keyword">bool</span><span class="special">(*</span><span class="keyword">this</span><span class="special">)</span> <span class="special">?</span> <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> <span class="special">:</span> <span class="keyword">static_cast</span><span class="special"><</span><span class="identifier">T</span><span class="special">>(</span><span class="identifier">f</span><span class="special">())</span></code>.
|
<span class="bold"><strong>Effects:</strong></span> <code class="computeroutput"><span class="keyword">if</span>
|
||||||
|
<span class="special">(*</span><span class="keyword">this</span><span class="special">)</span> <span class="keyword">return</span> <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> <span class="keyword">else</span> <span class="keyword">return</span>
|
||||||
|
<span class="identifier">f</span><span class="special">();</span></code>.
|
||||||
</li>
|
</li>
|
||||||
<li class="listitem">
|
<li class="listitem">
|
||||||
<span class="bold"><strong>Throws:</strong></span> Any exception thrown by the
|
<span class="bold"><strong>Notes:</strong></span> On compilers that do not support
|
||||||
selected constructor of <code class="computeroutput"><span class="identifier">T</span></code>
|
|
||||||
or by <code class="computeroutput"><span class="identifier">f</span></code>.
|
|
||||||
</li>
|
|
||||||
<li class="listitem">
|
|
||||||
<span class="bold"><strong>Notes:</strong></span> Function <code class="computeroutput"><span class="identifier">f</span></code>
|
|
||||||
is only evaluated if <code class="computeroutput"><span class="keyword">bool</span><span class="special">(*</span><span class="keyword">this</span><span class="special">)</span> <span class="special">==</span> <span class="keyword">false</span></code>. On compilers that do not support
|
|
||||||
ref-qualifiers on member functions this overload is not present.
|
ref-qualifiers on member functions this overload is not present.
|
||||||
</li>
|
</li>
|
||||||
</ul></div>
|
</ul></div>
|
||||||
|
@ -133,7 +133,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: June 18, 2014 at 14:36:35 GMT</small></p></td>
|
<td align="left"><p><small>Last revised: June 20, 2014 at 09:06:52 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>
|
||||||
|
@ -112,28 +112,6 @@ class typed_in_place_factory_base ;
|
|||||||
template<class T> void swap ( optional<T>& x, optional<T>& y );
|
template<class T> void swap ( optional<T>& x, optional<T>& y );
|
||||||
|
|
||||||
namespace optional_detail {
|
namespace optional_detail {
|
||||||
|
|
||||||
// converts type U to type T using only implicit conversions/constructors
|
|
||||||
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
|
|
||||||
template <typename TT, typename UU>
|
|
||||||
TT convert(UU && u)
|
|
||||||
{
|
|
||||||
return forward<UU>(u);
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
template <typename TT, typename UU>
|
|
||||||
TT convert(const UU& u)
|
|
||||||
{
|
|
||||||
return u;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename TT, typename UU>
|
|
||||||
TT convert(UU& u)
|
|
||||||
{
|
|
||||||
return u;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// This local class is used instead of that in "aligned_storage.hpp"
|
// This local class is used instead of that in "aligned_storage.hpp"
|
||||||
// because I've found the 'official' class to ICE BCB5.5
|
// because I've found the 'official' class to ICE BCB5.5
|
||||||
// when some types are used with optional<>
|
// when some types are used with optional<>
|
||||||
@ -1082,25 +1060,37 @@ class optional : public optional_detail::optional_base<T>
|
|||||||
template <class U>
|
template <class U>
|
||||||
value_type value_or ( U&& v ) const&
|
value_type value_or ( U&& v ) const&
|
||||||
{
|
{
|
||||||
return this->is_initialized() ? get() : optional_detail::convert<value_type>(boost::forward<U>(v));
|
if (this->is_initialized())
|
||||||
|
return get();
|
||||||
|
else
|
||||||
|
return boost::forward<U>(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class U>
|
template <class U>
|
||||||
value_type value_or ( U&& v ) &&
|
value_type value_or ( U&& v ) &&
|
||||||
{
|
{
|
||||||
return this->is_initialized() ? boost::move(get()) : optional_detail::convert<value_type>(boost::forward<U>(v));
|
if (this->is_initialized())
|
||||||
|
return boost::move(get());
|
||||||
|
else
|
||||||
|
return boost::forward<U>(v);
|
||||||
}
|
}
|
||||||
#elif !defined BOOST_NO_CXX11_RVALUE_REFERENCES
|
#elif !defined BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||||
template <class U>
|
template <class U>
|
||||||
value_type value_or ( U&& v ) const
|
value_type value_or ( U&& v ) const
|
||||||
{
|
{
|
||||||
return this->is_initialized() ? get() : optional_detail::convert<value_type>(boost::forward<U>(v));
|
if (this->is_initialized())
|
||||||
|
return get();
|
||||||
|
else
|
||||||
|
return boost::forward<U>(v);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
template <class U>
|
template <class U>
|
||||||
value_type value_or ( U const& v ) const
|
value_type value_or ( U const& v ) const
|
||||||
{
|
{
|
||||||
return this->is_initialized() ? get() : optional_detail::convert<value_type>(v);
|
if (this->is_initialized())
|
||||||
|
return get();
|
||||||
|
else
|
||||||
|
return v;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -1109,19 +1099,28 @@ class optional : public optional_detail::optional_base<T>
|
|||||||
template <typename F>
|
template <typename F>
|
||||||
value_type value_or_eval ( F f ) const&
|
value_type value_or_eval ( F f ) const&
|
||||||
{
|
{
|
||||||
return this->is_initialized() ? get() : optional_detail::convert<value_type>(f());
|
if (this->is_initialized())
|
||||||
|
return get();
|
||||||
|
else
|
||||||
|
return f();
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename F>
|
template <typename F>
|
||||||
value_type value_or_eval ( F f ) &&
|
value_type value_or_eval ( F f ) &&
|
||||||
{
|
{
|
||||||
return this->is_initialized() ? boost::move(get()) : optional_detail::convert<value_type>(f());
|
if (this->is_initialized())
|
||||||
|
return boost::move(get());
|
||||||
|
else
|
||||||
|
return f();
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
template <typename F>
|
template <typename F>
|
||||||
value_type value_or_eval ( F f ) const
|
value_type value_or_eval ( F f ) const
|
||||||
{
|
{
|
||||||
return this->is_initialized() ? get() : optional_detail::convert<value_type>(f());
|
if (this->is_initialized())
|
||||||
|
return get();
|
||||||
|
else
|
||||||
|
return f();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -149,7 +149,7 @@ int throw_()
|
|||||||
throw int();
|
throw int();
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_function_value_or_call()
|
void test_function_value_or_eval()
|
||||||
{
|
{
|
||||||
optional<int> o1 = 1;
|
optional<int> o1 = 1;
|
||||||
optional<int> oN;
|
optional<int> oN;
|
||||||
@ -237,7 +237,7 @@ int test_main( int, char* [] )
|
|||||||
{
|
{
|
||||||
test_function_value();
|
test_function_value();
|
||||||
test_function_value_or();
|
test_function_value_or();
|
||||||
test_function_value_or_call();
|
test_function_value_or_eval();
|
||||||
}
|
}
|
||||||
catch ( ... )
|
catch ( ... )
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user