Catching up with N4078

This commit is contained in:
Andrzej Krzemienski
2014-06-28 00:31:36 +02:00
parent c7200c4aed
commit 18b8c4bb18
9 changed files with 131 additions and 89 deletions

View File

@ -72,12 +72,14 @@
T* operator ->() ; ``[link reference_optional_operator_arrow __GO_TO__]`` T* operator ->() ; ``[link reference_optional_operator_arrow __GO_TO__]``
T const& operator *() const& ; ``[link reference_optional_operator_asterisk __GO_TO__]`` T const& operator *() const& ; ``[link reference_optional_operator_asterisk __GO_TO__]``
T& operator *() &; ``[link reference_optional_operator_asterisk __GO_TO__]`` T& operator *() & ; ``[link reference_optional_operator_asterisk __GO_TO__]``
T operator *() &&; ``[link reference_optional_operator_asterisk_move __GO_TO__]`` T operator *() && ; ``[link reference_optional_operator_asterisk_move __GO_TO__]``
T operator *() const&& ; ``[link reference_optional_operator_asterisk_move __GO_TO__]``
T const& value() const& ; ``[link reference_optional_value __GO_TO__]`` T const& value() const& ; ``[link reference_optional_value __GO_TO__]``
T& value() & ; ``[link reference_optional_value __GO_TO__]`` T& value() & ; ``[link reference_optional_value __GO_TO__]``
T value() && ; ``[link reference_optional_value_move __GO_TO__]`` T value() && ; ``[link reference_optional_value_move __GO_TO__]``
T value() const&& ; ``[link reference_optional_value_move __GO_TO__]``
template<class U> T value_or( U && v ) const& ; ``[link reference_optional_value_or __GO_TO__]`` template<class U> T value_or( U && v ) const& ; ``[link reference_optional_value_or __GO_TO__]``
template<class U> T value_or( U && v ) && ; ``[link reference_optional_value_or_move __GO_TO__]`` template<class U> T value_or( U && v ) && ; ``[link reference_optional_value_or_move __GO_TO__]``
@ -863,22 +865,24 @@ __SPACE__
[#reference_optional_operator_asterisk_move] [#reference_optional_operator_asterisk_move]
[: `T optional<T` ['(not a ref)]`>::operator*() &&;`] [: `T optional<T` ['(not a ref)]`>::operator*() &&;`]
[: `T optional<T` ['(not a ref)]`>::operator*() const&&;`]
* [*Requires:] `T` is __MOVE_CONSTRUCTIBLE__ and `*this` is initialized. * [*Requires:] `*this` contains a value.
* [*Returns:] A move-constructed copy the contained value. * [*Effects:] Equivalent to `return std::move(*val);`.
* [*Throws:] Whatever the `T`'s constructor selected for the move throws. * [*Remarks:] If `T` is not __MOVE_CONSTRUCTIBLE__, the program is ill-formed.
* [*Notes:] The requirement is asserted via `BOOST_ASSERT()`. On compilers that do not support ref-qualifiers on member functions this overload is not present. * [*Notes:] The requirement is asserted via `BOOST_ASSERT()`. On GCC compiler the second overload is not present, as this compiler incorrectly implements binding of references to const prvalues. On compilers that do not support ref-qualifiers on member functions both these overloads are not present.
__SPACE__ __SPACE__
[: `T const& optional<T&>::operator*() const& ;`] [: `T & optional<T&>::operator*() const& ;`]
[: `T & optional<T&>::operator*() & ;`] [: `T & optional<T&>::operator*() & ;`]
[: `T & optional<T&>::operator*() && ;`] [: `T & optional<T&>::operator*() && ;`]
[: `T & optional<T&>::operator*() const&& ;`]
* [*Requires: ] `*this` is initialized * [*Requires: ] `*this` is initialized
* [*Returns:] [_The] reference contained. * [*Returns:] [_The] reference contained.
* [*Throws:] Nothing. * [*Throws:] Nothing.
* [*Notes:] The requirement is asserted via `BOOST_ASSERT()`. On compilers that do not support ref-qualifiers on member functions these three overloads are replaced with the classical two: a `const` and non-`const` member functions. * [*Notes:] The requirement is asserted via `BOOST_ASSERT()`. On GCC compiler the fourth overload is not present, as this compiler incorrectly implements binding of references to const prvalues. On compilers that do not support ref-qualifiers on member functions these four overloads are replaced with the classical two: a `const` and non-`const` member functions.
* [*Example:] * [*Example:]
`` ``
T v ; T v ;
@ -897,8 +901,7 @@ __SPACE__
[: `T const& optional<T>::value() const& ;`] [: `T const& optional<T>::value() const& ;`]
[: `T& optional<T>::value() & ;`] [: `T& optional<T>::value() & ;`]
* [*Returns:] A reference to the contained value, if `*this` is initialized. * [*Effects:] Equivalent to `return bool(*this) ? *val : throw bad_optional_access();`.
* [*Throws:] An instance of `bad_optional_access`, if `*this` is not initialized.
* [*Notes:] On compilers that do not support ref-qualifiers on member functions these two overloads are replaced with the classical two: a `const` and non-`const` member functions. * [*Notes:] On compilers that do not support ref-qualifiers on member functions these two overloads are replaced with the classical two: a `const` and non-`const` member functions.
* [*Example:] * [*Example:]
`` ``
@ -919,12 +922,12 @@ __SPACE__
[#reference_optional_value_move] [#reference_optional_value_move]
[: `T optional<T>::value() && ;`] [: `T optional<T>::value() && ;`]
[: `T optional<T>::value() const&& ;`]
* [*Requires:] `T` is __MOVE_CONSTRUCTIBLE__. * [*Effects:] Equivalent to `return bool(*this) ? std::move(*val) : throw bad_optional_access();`.
* [*Returns:] A move-constructed copy of the contained value, if `*this` is initialized. * [*Remarks:] If `T` is not __MOVE_CONSTRUCTIBLE__, the program is ill-formed.
* [*Throws:] An instance of `bad_optional_access`, if `*this` is not initialized. * [*Notes:] On GCC compiler the second overload is not present, as this compiler incorrectly implements binding of references to const prvalues. On compilers that do not support ref-qualifiers on member functions both these overloads are not present.
* [*Notes:] On compilers that do not support ref-qualifiers on member functions this overload is not present.
__SPACE__ __SPACE__
@ -933,8 +936,8 @@ __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`. * [*Effects:] Equivalent to `if (*this) return **this; else return std::forward<U>(v);`.
* [*Effects:] `if (*this) return **this; else return std::forward<U>(v);`. * [*Remarks:] If `T` is not __COPY_CONSTRUCTIBLE__ or `U &&` is not convertible to `T`, the program is ill-formed.
* [*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 +946,8 @@ __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`. * [*Effects:] Equivalent to `if (*this) return std::move(**this); else return std::forward<U>(v);`.
* [*Effects:] `if (*this) return std::move(**this); else return std::forward<U>(v);`. * [*Remarks:] If `T` is not __MOVE_CONSTRUCTIBLE__ or `U &&` is not convertible to `T`, the program is ill-formed.
* [*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__

View File

@ -1337,33 +1337,37 @@
<code class="computeroutput"><span class="identifier">T</span> <span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span></code> <code class="computeroutput"><span class="identifier">T</span> <span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span></code>
<span class="emphasis"><em>(not a ref)</em></span><code class="computeroutput"><span class="special">&gt;::</span><span class="keyword">operator</span><span class="special">*()</span> <span class="special">&amp;&amp;;</span></code> <span class="emphasis"><em>(not a ref)</em></span><code class="computeroutput"><span class="special">&gt;::</span><span class="keyword">operator</span><span class="special">*()</span> <span class="special">&amp;&amp;;</span></code>
</p></blockquote></div> </p></blockquote></div>
<div class="blockquote"><blockquote class="blockquote"><p>
<code class="computeroutput"><span class="identifier">T</span> <span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span></code>
<span class="emphasis"><em>(not a ref)</em></span><code class="computeroutput"><span class="special">&gt;::</span><span class="keyword">operator</span><span class="special">*()</span> <span class="keyword">const</span><span class="special">&amp;&amp;;</span></code>
</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>Requires:</strong></span> <code class="computeroutput"><span class="identifier">T</span></code> <span class="bold"><strong>Requires:</strong></span> <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> contains a value.
is <code class="computeroutput"><span class="identifier">MoveConstructible</span></code>
and <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code>
is initialized.
</li> </li>
<li class="listitem"> <li class="listitem">
<span class="bold"><strong>Returns:</strong></span> A move-constructed copy the <span class="bold"><strong>Effects:</strong></span> Equivalent to <code class="computeroutput"><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="identifier">val</span><span class="special">);</span></code>.
contained value.
</li> </li>
<li class="listitem"> <li class="listitem">
<span class="bold"><strong>Throws:</strong></span> Whatever the <code class="computeroutput"><span class="identifier">T</span></code>'s <span class="bold"><strong>Remarks:</strong></span> If <code class="computeroutput"><span class="identifier">T</span></code>
constructor selected for the move throws. is not <code class="computeroutput"><span class="identifier">MoveConstructible</span></code>,
the program is ill-formed.
</li> </li>
<li class="listitem"> <li class="listitem">
<span class="bold"><strong>Notes:</strong></span> The requirement is asserted via <span class="bold"><strong>Notes:</strong></span> The requirement is asserted via
<code class="computeroutput"><span class="identifier">BOOST_ASSERT</span><span class="special">()</span></code>. <code class="computeroutput"><span class="identifier">BOOST_ASSERT</span><span class="special">()</span></code>.
On compilers that do not support ref-qualifiers on member functions this On GCC compiler the second overload is not present, as this compiler
overload is not present. incorrectly implements binding of references to const prvalues. On compilers
that do not support ref-qualifiers on member functions both these overloads
are not present.
</li> </li>
</ul></div> </ul></div>
<p> <p>
<span class="inlinemediaobject"><img src="../../images/space.png" alt="space"></span> <span class="inlinemediaobject"><img src="../../images/space.png" alt="space"></span>
</p> </p>
<div class="blockquote"><blockquote class="blockquote"><p> <div class="blockquote"><blockquote class="blockquote"><p>
<code class="computeroutput"><span class="identifier">T</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&amp;&gt;::</span><span class="keyword">operator</span><span class="special">*()</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="special">;</span></code> <code class="computeroutput"><span class="identifier">T</span> <span class="special">&amp;</span>
<span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&amp;&gt;::</span><span class="keyword">operator</span><span class="special">*()</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="special">;</span></code>
</p></blockquote></div> </p></blockquote></div>
<div class="blockquote"><blockquote class="blockquote"><p> <div class="blockquote"><blockquote class="blockquote"><p>
<code class="computeroutput"><span class="identifier">T</span> <span class="special">&amp;</span> <code class="computeroutput"><span class="identifier">T</span> <span class="special">&amp;</span>
@ -1373,6 +1377,11 @@
<code class="computeroutput"><span class="identifier">T</span> <span class="special">&amp;</span> <code class="computeroutput"><span class="identifier">T</span> <span class="special">&amp;</span>
<span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&amp;&gt;::</span><span class="keyword">operator</span><span class="special">*()</span> <span class="special">&amp;&amp;</span> <span class="special">;</span></code> <span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&amp;&gt;::</span><span class="keyword">operator</span><span class="special">*()</span> <span class="special">&amp;&amp;</span> <span class="special">;</span></code>
</p></blockquote></div> </p></blockquote></div>
<div class="blockquote"><blockquote class="blockquote"><p>
<code class="computeroutput"><span class="identifier">T</span> <span class="special">&amp;</span>
<span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&amp;&gt;::</span><span class="keyword">operator</span><span class="special">*()</span> <span class="keyword">const</span><span class="special">&amp;&amp;</span>
<span class="special">;</span></code>
</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>Requires: </strong></span> <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> is initialized <span class="bold"><strong>Requires: </strong></span> <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> is initialized
@ -1387,9 +1396,11 @@
<li class="listitem"> <li class="listitem">
<span class="bold"><strong>Notes:</strong></span> The requirement is asserted via <span class="bold"><strong>Notes:</strong></span> The requirement is asserted via
<code class="computeroutput"><span class="identifier">BOOST_ASSERT</span><span class="special">()</span></code>. <code class="computeroutput"><span class="identifier">BOOST_ASSERT</span><span class="special">()</span></code>.
On compilers that do not support ref-qualifiers on member functions these On GCC compiler the fourth overload is not present, as this compiler
three overloads are replaced with the classical two: a <code class="computeroutput"><span class="keyword">const</span></code> and non-<code class="computeroutput"><span class="keyword">const</span></code> incorrectly implements binding of references to const prvalues. On compilers
member functions. that do not support ref-qualifiers on member functions these four overloads
are replaced with the classical two: a <code class="computeroutput"><span class="keyword">const</span></code>
and non-<code class="computeroutput"><span class="keyword">const</span></code> member functions.
</li> </li>
<li class="listitem"> <li class="listitem">
<span class="bold"><strong>Example:</strong></span> <span class="bold"><strong>Example:</strong></span>
@ -1415,13 +1426,7 @@
</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>Returns:</strong></span> A reference to the contained <span class="bold"><strong>Effects:</strong></span> Equivalent to <code class="computeroutput"><span class="keyword">return</span> <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="identifier">val</span> <span class="special">:</span> <span class="keyword">throw</span> <span class="identifier">bad_optional_access</span><span class="special">();</span></code>.
value, if <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code>
is initialized.
</li>
<li class="listitem">
<span class="bold"><strong>Throws:</strong></span> An instance of <code class="computeroutput"><span class="identifier">bad_optional_access</span></code>, if <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code>
is not initialized.
</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
@ -1452,22 +1457,24 @@
<code class="computeroutput"><span class="identifier">T</span> <span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;::</span><span class="identifier">value</span><span class="special">()</span> <span class="special">&amp;&amp;</span> <code class="computeroutput"><span class="identifier">T</span> <span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;::</span><span class="identifier">value</span><span class="special">()</span> <span class="special">&amp;&amp;</span>
<span class="special">;</span></code> <span class="special">;</span></code>
</p></blockquote></div> </p></blockquote></div>
<div class="blockquote"><blockquote class="blockquote"><p>
<code class="computeroutput"><span class="identifier">T</span> <span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;::</span><span class="identifier">value</span><span class="special">()</span> <span class="keyword">const</span><span class="special">&amp;&amp;</span> <span class="special">;</span></code>
</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>Requires:</strong></span> <code class="computeroutput"><span class="identifier">T</span></code> <span class="bold"><strong>Effects:</strong></span> Equivalent to <code class="computeroutput"><span class="keyword">return</span> <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="identifier">val</span><span class="special">)</span> <span class="special">:</span> <span class="keyword">throw</span>
is <code class="computeroutput"><span class="identifier">MoveConstructible</span></code>. <span class="identifier">bad_optional_access</span><span class="special">();</span></code>.
</li> </li>
<li class="listitem"> <li class="listitem">
<span class="bold"><strong>Returns:</strong></span> A move-constructed copy of <span class="bold"><strong>Remarks:</strong></span> If <code class="computeroutput"><span class="identifier">T</span></code>
the contained value, if <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> is initialized. is not <code class="computeroutput"><span class="identifier">MoveConstructible</span></code>,
the program is ill-formed.
</li> </li>
<li class="listitem"> <li class="listitem">
<span class="bold"><strong>Throws:</strong></span> An instance of <code class="computeroutput"><span class="identifier">bad_optional_access</span></code>, if <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> <span class="bold"><strong>Notes:</strong></span> On GCC compiler the second overload
is not initialized. is not present, as this compiler incorrectly implements binding of references
</li> to const prvalues. On compilers that do not support ref-qualifiers on
<li class="listitem"> member functions both these overloads are not present.
<span class="bold"><strong>Notes:</strong></span> On compilers that do not support
ref-qualifiers on member functions this overload is not present.
</li> </li>
</ul></div> </ul></div>
<p> <p>
@ -1481,13 +1488,14 @@
</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>Requires:</strong></span> <code class="computeroutput"><span class="identifier">T</span></code> <span class="bold"><strong>Effects:</strong></span> Equivalent to <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>
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">U</span> <span class="special">&amp;&amp;</span></code> <span class="identifier">std</span><span class="special">::</span><span class="identifier">forward</span><span class="special">&lt;</span><span class="identifier">U</span><span class="special">&gt;(</span><span class="identifier">v</span><span class="special">);</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>Effects:</strong></span> <code class="computeroutput"><span class="keyword">if</span> <span class="bold"><strong>Remarks:</strong></span> If <code class="computeroutput"><span class="identifier">T</span></code>
<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">&lt;</span><span class="identifier">U</span><span class="special">&gt;(</span><span class="identifier">v</span><span class="special">);</span></code>. is not <a href="../../../../../utility/CopyConstructible.html" target="_top"><code class="computeroutput"><span class="identifier">CopyConstructible</span></code></a> or <code class="computeroutput"><span class="identifier">U</span> <span class="special">&amp;&amp;</span></code>
is not convertible to <code class="computeroutput"><span class="identifier">T</span></code>,
the program is ill-formed.
</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
@ -1507,15 +1515,14 @@
</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>Requires:</strong></span> <code class="computeroutput"><span class="identifier">T</span></code> <span class="bold"><strong>Effects:</strong></span> Equivalent to <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">std</span><span class="special">::</span><span class="identifier">forward</span><span class="special">&lt;</span><span class="identifier">U</span><span class="special">&gt;(</span><span class="identifier">v</span><span class="special">);</span></code>.
is <code class="computeroutput"><span class="identifier">MoveConstructible</span></code>
and <code class="computeroutput"><span class="identifier">U</span> <span class="special">&amp;&amp;</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>Effects:</strong></span> <code class="computeroutput"><span class="keyword">if</span> <span class="bold"><strong>Remarks:</strong></span> If <code class="computeroutput"><span class="identifier">T</span></code>
<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> is not <code class="computeroutput"><span class="identifier">MoveConstructible</span></code>
<span class="identifier">std</span><span class="special">::</span><span class="identifier">forward</span><span class="special">&lt;</span><span class="identifier">U</span><span class="special">&gt;(</span><span class="identifier">v</span><span class="special">);</span></code>. or <code class="computeroutput"><span class="identifier">U</span> <span class="special">&amp;&amp;</span></code>
is not convertible to <code class="computeroutput"><span class="identifier">T</span></code>,
the program is ill-formed.
</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

View File

@ -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 20, 2014 at 20:25:26 GMT</small></p></td> <td align="left"><p><small>Last revised: June 27, 2014 at 22:17:04 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>

View File

@ -96,12 +96,14 @@
<span class="identifier">T</span><span class="special">*</span> <span class="keyword">operator</span> <span class="special">-&gt;()</span> <span class="special">;</span> <a class="link" href="../boost_optional/reference/detailed_semantics.html#reference_optional_operator_arrow"><span class="inlinemediaobject"><img src="../images/callouts/R.png" alt="R"></span></a> <span class="identifier">T</span><span class="special">*</span> <span class="keyword">operator</span> <span class="special">-&gt;()</span> <span class="special">;</span> <a class="link" href="../boost_optional/reference/detailed_semantics.html#reference_optional_operator_arrow"><span class="inlinemediaobject"><img src="../images/callouts/R.png" alt="R"></span></a>
<span class="identifier">T</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="keyword">operator</span> <span class="special">*()</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="special">;</span> <a class="link" href="../boost_optional/reference/detailed_semantics.html#reference_optional_operator_asterisk"><span class="inlinemediaobject"><img src="../images/callouts/R.png" alt="R"></span></a> <span class="identifier">T</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="keyword">operator</span> <span class="special">*()</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="special">;</span> <a class="link" href="../boost_optional/reference/detailed_semantics.html#reference_optional_operator_asterisk"><span class="inlinemediaobject"><img src="../images/callouts/R.png" alt="R"></span></a>
<span class="identifier">T</span><span class="special">&amp;</span> <span class="keyword">operator</span> <span class="special">*()</span> <span class="special">&amp;;</span> <a class="link" href="../boost_optional/reference/detailed_semantics.html#reference_optional_operator_asterisk"><span class="inlinemediaobject"><img src="../images/callouts/R.png" alt="R"></span></a> <span class="identifier">T</span><span class="special">&amp;</span> <span class="keyword">operator</span> <span class="special">*()</span> <span class="special">&amp;</span> <span class="special">;</span> <a class="link" href="../boost_optional/reference/detailed_semantics.html#reference_optional_operator_asterisk"><span class="inlinemediaobject"><img src="../images/callouts/R.png" alt="R"></span></a>
<span class="identifier">T</span> <span class="keyword">operator</span> <span class="special">*()</span> <span class="special">&amp;&amp;;</span> <a class="link" href="../boost_optional/reference/detailed_semantics.html#reference_optional_operator_asterisk_move"><span class="inlinemediaobject"><img src="../images/callouts/R.png" alt="R"></span></a> <span class="identifier">T</span> <span class="keyword">operator</span> <span class="special">*()</span> <span class="special">&amp;&amp;</span> <span class="special">;</span> <a class="link" href="../boost_optional/reference/detailed_semantics.html#reference_optional_operator_asterisk_move"><span class="inlinemediaobject"><img src="../images/callouts/R.png" alt="R"></span></a>
<span class="identifier">T</span> <span class="keyword">operator</span> <span class="special">*()</span> <span class="keyword">const</span><span class="special">&amp;&amp;</span> <span class="special">;</span> <a class="link" href="../boost_optional/reference/detailed_semantics.html#reference_optional_operator_asterisk_move"><span class="inlinemediaobject"><img src="../images/callouts/R.png" alt="R"></span></a>
<span class="identifier">T</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">value</span><span class="special">()</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="special">;</span> <a class="link" href="../boost_optional/reference/detailed_semantics.html#reference_optional_value"><span class="inlinemediaobject"><img src="../images/callouts/R.png" alt="R"></span></a> <span class="identifier">T</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">value</span><span class="special">()</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="special">;</span> <a class="link" href="../boost_optional/reference/detailed_semantics.html#reference_optional_value"><span class="inlinemediaobject"><img src="../images/callouts/R.png" alt="R"></span></a>
<span class="identifier">T</span><span class="special">&amp;</span> <span class="identifier">value</span><span class="special">()</span> <span class="special">&amp;</span> <span class="special">;</span> <a class="link" href="../boost_optional/reference/detailed_semantics.html#reference_optional_value"><span class="inlinemediaobject"><img src="../images/callouts/R.png" alt="R"></span></a> <span class="identifier">T</span><span class="special">&amp;</span> <span class="identifier">value</span><span class="special">()</span> <span class="special">&amp;</span> <span class="special">;</span> <a class="link" href="../boost_optional/reference/detailed_semantics.html#reference_optional_value"><span class="inlinemediaobject"><img src="../images/callouts/R.png" alt="R"></span></a>
<span class="identifier">T</span> <span class="identifier">value</span><span class="special">()</span> <span class="special">&amp;&amp;</span> <span class="special">;</span> <a class="link" href="../boost_optional/reference/detailed_semantics.html#reference_optional_value_move"><span class="inlinemediaobject"><img src="../images/callouts/R.png" alt="R"></span></a> <span class="identifier">T</span> <span class="identifier">value</span><span class="special">()</span> <span class="special">&amp;&amp;</span> <span class="special">;</span> <a class="link" href="../boost_optional/reference/detailed_semantics.html#reference_optional_value_move"><span class="inlinemediaobject"><img src="../images/callouts/R.png" alt="R"></span></a>
<span class="identifier">T</span> <span class="identifier">value</span><span class="special">()</span> <span class="keyword">const</span><span class="special">&amp;&amp;</span> <span class="special">;</span> <a class="link" href="../boost_optional/reference/detailed_semantics.html#reference_optional_value_move"><span class="inlinemediaobject"><img src="../images/callouts/R.png" alt="R"></span></a>
<span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">U</span><span class="special">&gt;</span> <span class="identifier">T</span> <span class="identifier">value_or</span><span class="special">(</span> <span class="identifier">U</span> <span class="special">&amp;&amp;</span> <span class="identifier">v</span> <span class="special">)</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="special">;</span> <a class="link" href="../boost_optional/reference/detailed_semantics.html#reference_optional_value_or"><span class="inlinemediaobject"><img src="../images/callouts/R.png" alt="R"></span></a> <span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">U</span><span class="special">&gt;</span> <span class="identifier">T</span> <span class="identifier">value_or</span><span class="special">(</span> <span class="identifier">U</span> <span class="special">&amp;&amp;</span> <span class="identifier">v</span> <span class="special">)</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="special">;</span> <a class="link" href="../boost_optional/reference/detailed_semantics.html#reference_optional_value_or"><span class="inlinemediaobject"><img src="../images/callouts/R.png" alt="R"></span></a>
<span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">U</span><span class="special">&gt;</span> <span class="identifier">T</span> <span class="identifier">value_or</span><span class="special">(</span> <span class="identifier">U</span> <span class="special">&amp;&amp;</span> <span class="identifier">v</span> <span class="special">)</span> <span class="special">&amp;&amp;</span> <span class="special">;</span> <a class="link" href="../boost_optional/reference/detailed_semantics.html#reference_optional_value_or_move"><span class="inlinemediaobject"><img src="../images/callouts/R.png" alt="R"></span></a> <span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">U</span><span class="special">&gt;</span> <span class="identifier">T</span> <span class="identifier">value_or</span><span class="special">(</span> <span class="identifier">U</span> <span class="special">&amp;&amp;</span> <span class="identifier">v</span> <span class="special">)</span> <span class="special">&amp;&amp;</span> <span class="special">;</span> <a class="link" href="../boost_optional/reference/detailed_semantics.html#reference_optional_value_or_move"><span class="inlinemediaobject"><img src="../images/callouts/R.png" alt="R"></span></a>

View File

@ -19,8 +19,9 @@ namespace boost {
class bad_optional_access : public std::logic_error class bad_optional_access : public std::logic_error
{ {
public: public:
explicit bad_optional_access(const std::string& what_arg) : std::logic_error(what_arg) {} bad_optional_access()
explicit bad_optional_access(const char* what_arg) : std::logic_error(what_arg) {} : std::logic_error("Attempted to access the value of an uninitialized optional object.")
{}
}; };
} // namespace boost } // namespace boost

View File

@ -1005,13 +1005,16 @@ class optional : public optional_detail::optional_base<T>
// the behaviour is UNDEFINED // the behaviour is UNDEFINED
// No-throw // No-throw
#ifndef BOOST_NO_CXX11_REF_QUALIFIERS #ifndef BOOST_NO_CXX11_REF_QUALIFIERS
reference_const_type operator *() const& { return this->get() ; } reference_const_type operator *() const& { return this->get() ; }
reference_type operator *() & { return this->get() ; } reference_type operator *() & { return this->get() ; }
value_type operator *() && { return boost::move(this->get()) ; } value_type operator *() && { return boost::move(this->get()) ; }
#ifdef BOOST_CLANG
value_type operator *() const&& { return boost::move(this->get()) ; }
#endif
#else #else
reference_const_type operator *() const { return this->get() ; } reference_const_type operator *() const { return this->get() ; }
reference_type operator *() { return this->get() ; } reference_type operator *() { return this->get() ; }
#endif #endif // !defined BOOST_NO_CXX11_REF_QUALIFIERS
#ifndef BOOST_NO_CXX11_REF_QUALIFIERS #ifndef BOOST_NO_CXX11_REF_QUALIFIERS
reference_const_type value() const& reference_const_type value() const&
@ -1019,7 +1022,7 @@ class optional : public optional_detail::optional_base<T>
if (this->is_initialized()) if (this->is_initialized())
return this->get() ; return this->get() ;
else else
throw_exception(bad_optional_access("Attempted to access the value of an uninitialized optional object.")); throw_exception(bad_optional_access());
} }
reference_type value() & reference_type value() &
@ -1027,7 +1030,7 @@ class optional : public optional_detail::optional_base<T>
if (this->is_initialized()) if (this->is_initialized())
return this->get() ; return this->get() ;
else else
throw_exception(bad_optional_access("Attempted to access the value of an uninitialized optional object.")); throw_exception(bad_optional_access());
} }
value_type value() && value_type value() &&
@ -1035,15 +1038,25 @@ class optional : public optional_detail::optional_base<T>
if (this->is_initialized()) if (this->is_initialized())
return boost::move(this->get()) ; return boost::move(this->get()) ;
else else
throw_exception(bad_optional_access("Attempted to access the value of an uninitialized optional object.")); throw_exception(bad_optional_access());
} }
#ifdef BOOST_CLANG
value_type value() const&&
{
if (this->is_initialized())
return boost::move(this->get()) ;
else
throw_exception(bad_optional_access());
}
#endif
#else #else
reference_const_type value() const reference_const_type value() const
{ {
if (this->is_initialized()) if (this->is_initialized())
return this->get() ; return this->get() ;
else else
throw_exception(bad_optional_access("Attempted to access the value of an uninitialized optional object.")); throw_exception(bad_optional_access());
} }
reference_type value() reference_type value()
@ -1051,7 +1064,7 @@ class optional : public optional_detail::optional_base<T>
if (this->is_initialized()) if (this->is_initialized())
return this->get() ; return this->get() ;
else else
throw_exception(bad_optional_access("Attempted to access the value of an uninitialized optional object.")); throw_exception(bad_optional_access());
} }
#endif #endif

View File

@ -291,7 +291,7 @@ void test_uninitialized_access( T const* )
{ {
// This should throw because 'def' is uninitialized // This should throw because 'def' is uninitialized
T const& n = def.get() ; T const& n = def.get() ;
unused_variable(n); boost::ignore_unused(n);
passed = true ; passed = true ;
} }
catch (...) {} catch (...) {}
@ -302,7 +302,7 @@ void test_uninitialized_access( T const* )
{ {
// This should throw because 'def' is uninitialized // This should throw because 'def' is uninitialized
T const& n = *def ; T const& n = *def ;
unused_variable(n); boost::ignore_unused(n);
passed = true ; passed = true ;
} }
catch (...) {} catch (...) {}
@ -312,7 +312,7 @@ void test_uninitialized_access( T const* )
try try
{ {
T v(5) ; T v(5) ;
unused_variable(v); boost::ignore_unused(v);
// This should throw because 'def' is uninitialized // This should throw because 'def' is uninitialized
*def = v ; *def = v ;
passed = true ; passed = true ;
@ -325,7 +325,7 @@ void test_uninitialized_access( T const* )
{ {
// This should throw because 'def' is uninitialized // This should throw because 'def' is uninitialized
T v = *(def.operator->()) ; T v = *(def.operator->()) ;
unused_variable(v); boost::ignore_unused(v);
passed = true ; passed = true ;
} }
catch (...) {} catch (...) {}

View File

@ -1,4 +1,5 @@
// Copyright (C) 2003, Fernando Luis Cacciola Carballal. // Copyright (C) 2003, Fernando Luis Cacciola Carballal.
// Copyright (C) 2014, Andrzej Krzemienski.
// //
// Use, modification, and distribution is subject to the Boost Software // Use, modification, and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
@ -9,6 +10,8 @@
// You are welcome to contact the author at: // You are welcome to contact the author at:
// fernando_cacciola@hotmail.com // fernando_cacciola@hotmail.com
// //
#include <boost/core/ignore_unused.hpp>
#ifdef ENABLE_TRACE #ifdef ENABLE_TRACE
#define TRACE(msg) std::cout << msg << std::endl ; #define TRACE(msg) std::cout << msg << std::endl ;
#else #else
@ -37,7 +40,6 @@ void assertion_failed (char const * expr, char const * func, char const * file,
using boost::optional ; using boost::optional ;
template<class T> inline void unused_variable ( const T& ) {}
#ifdef BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP #ifdef BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP
using boost::swap ; using boost::swap ;

View File

@ -85,7 +85,7 @@ void test_function_value_for()
{ {
T& v = o0.value(); T& v = o0.value();
BOOST_CHECK(false); BOOST_CHECK(false);
unused_variable(v); boost::ignore_unused(v);
} }
catch(boost::bad_optional_access const&) catch(boost::bad_optional_access const&)
{ {
@ -194,6 +194,19 @@ void test_function_value_or_eval()
} }
} }
const optional<std::string> makeConstOptVal()
{
return std::string("something");
}
void test_const_move()
{
std::string s5 = *makeConstOptVal();
std::string s6 = makeConstOptVal().value();
boost::ignore_unused(s5);
boost::ignore_unused(s6);
}
#ifndef BOOST_NO_CXX11_REF_QUALIFIERS #ifndef BOOST_NO_CXX11_REF_QUALIFIERS
struct MoveOnly struct MoveOnly
@ -223,13 +236,13 @@ void test_move_only_getters()
MoveOnly m2 = makeMoveOnly().value(); MoveOnly m2 = makeMoveOnly().value();
MoveOnly m3 = makeMoveOnly().value_or(MoveOnly(1)); MoveOnly m3 = makeMoveOnly().value_or(MoveOnly(1));
MoveOnly m4 = makeMoveOnly().value_or_eval(moveOnlyDefault); MoveOnly m4 = makeMoveOnly().value_or_eval(moveOnlyDefault);
unused_variable(m1); boost::ignore_unused(m1);
unused_variable(m2); boost::ignore_unused(m2);
unused_variable(m3); boost::ignore_unused(m3);
unused_variable(m4); boost::ignore_unused(m4);
} }
#endif #endif // !defined BOOST_NO_CXX11_REF_QUALIFIERS
int test_main( int, char* [] ) int test_main( int, char* [] )
{ {
@ -238,6 +251,7 @@ int test_main( int, char* [] )
test_function_value(); test_function_value();
test_function_value_or(); test_function_value_or();
test_function_value_or_eval(); test_function_value_or_eval();
test_const_move();
} }
catch ( ... ) catch ( ... )
{ {