This commit is contained in:
Andrzej Krzemienski
2015-03-09 11:50:10 +01:00
parent 59266a2630
commit 0a8a798c3a
10 changed files with 107 additions and 22 deletions

View File

@ -15,11 +15,13 @@
namespace boost {
template<class T>
template <class T>
class optional
{
public :
public :
typedef T value_type;
// (If T is of reference type, the parameters and results by reference are by value)
optional () noexcept ; ``[link reference_optional_constructor __GO_TO__]``
@ -1137,9 +1139,8 @@ __SPACE__
* [*Requires:] `T` shall meet requirements of __SGI_EQUALITY_COMPARABLE__.
* [*Returns:] If both `x` and `y` are initialized, `(*x == *y)`. If only
`x` or `y` is initialized, `false`. If both are uninitialized, `true`.
* [*Notes:] Pointers have shallow relational operators while `optional` has
deep relational operators. Do not use `operator==` directly in generic
code which expect to be given either an `optional<T>` or a pointer; use
* [*Notes:] This definition guarantees that `optional<T>` not containing a value is compared unequal to any `optional<T>` containing any value, and equal to any other `optional<T>` not containing a value.
Pointers have shallow relational operators while `optional` has deep relational operators. Do not use `operator==` directly in generic code which expect to be given either an `optional<T>` or a pointer; use
__FUNCTION_EQUAL_POINTEES__ instead
* [*Example:]
``
@ -1166,8 +1167,8 @@ __SPACE__
* [*Requires:] Expression `*x < *y` shall be well-formed and its result shall be convertible to `bool`.
* [*Returns:] `(!y) ? false : (!x) ? true : *x < *y`.
* [*Notes:] Pointers have shallow relational operators while `optional` has
deep relational operators. Do not use `operator<` directly in generic code
* [*Notes:] This definition guarantees that `optional<T>` not containing a value is ordered as less than any `optional<T>` containing any value, and equivalent to any other `optional<T>` not containing a value.
Pointers have shallow relational operators while `optional` has deep relational operators. Do not use `operator<` directly in generic code
which expect to be given either an `optional<T>` or a pointer; use __FUNCTION_LESS_POINTEES__ instead. `T` need not be __SGI_LESS_THAN_COMPARABLE__. Only single `operator<` is required. Other relational operations are defined in terms of this one. If `T`'s `operator<` satisfies the axioms of __SGI_LESS_THAN_COMPARABLE__ (transitivity, antisymmetry and irreflexivity), `optinal<T>` is __SGI_LESS_THAN_COMPARABLE__.
* [*Example:]
``

View File

@ -17,7 +17,8 @@
* Improved the trick that prevents streaming out `optional` without header `optional_io.hpp` by using safe-bool idiom. This addresses [@https://svn.boost.org/trac/boost/ticket/10825 Trac #10825]
* IOStream operators are now mentioned in documentation.
* Added a way to manually disable move semantics: just define macro `BOOST_OPTIONAL_CONFIG_NO_RVALUE_REFERENCES`. This can be used to work around [@https://svn.boost.org/trac/boost/ticket/10399 Trac #10399]
* It is no longer possible to assign `optional<U>` to `optional<T>` when `U` is not assignable or convertible to `T`.
* It is no longer possible to assign `optional<U>` to `optional<T>` when `U` is not assignable or convertible to `T` ([@https://svn.boost.org/trac/boost/ticket/11087 Trac #11087]).
* Value accessors now work correctly on rvalues of `optional<T&>` ([@https://svn.boost.org/trac/boost/ticket/10839 Trac #10839]).
[heading Boost Release 1.57]

View File

@ -2028,9 +2028,13 @@
If both are uninitialized, <code class="computeroutput"><span class="keyword">true</span></code>.
</li>
<li class="listitem">
<span class="bold"><strong>Notes:</strong></span> Pointers have shallow relational
operators while <code class="computeroutput"><span class="identifier">optional</span></code>
has deep relational operators. Do not use <code class="computeroutput"><span class="keyword">operator</span><span class="special">==</span></code> directly in generic code which expect
<span class="bold"><strong>Notes:</strong></span> This definition guarantees that
<code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;</span></code>
not containing a value is compared unequal to any <code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;</span></code> containing any value, and equal to
any other <code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;</span></code>
not containing a value. Pointers have shallow relational operators while
<code class="computeroutput"><span class="identifier">optional</span></code> has deep relational
operators. Do not use <code class="computeroutput"><span class="keyword">operator</span><span class="special">==</span></code> directly in generic code which expect
to be given either an <code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;</span></code> or a pointer; use <a href="../../../../../utility/OptionalPointee.html#equal" target="_top"><code class="computeroutput"><span class="identifier">equal_pointees</span><span class="special">()</span></code></a>
instead
</li>
@ -2070,8 +2074,11 @@
<span class="special">:</span> <span class="special">*</span><span class="identifier">x</span> <span class="special">&lt;</span> <span class="special">*</span><span class="identifier">y</span></code>.
</li>
<li class="listitem">
<span class="bold"><strong>Notes:</strong></span> Pointers have shallow relational
operators while <code class="computeroutput"><span class="identifier">optional</span></code>
<span class="bold"><strong>Notes:</strong></span> This definition guarantees that
<code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;</span></code>
not containing a value is ordered as less than any <code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;</span></code> containing any value, and equivalent
to any other <code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;</span></code> not containing a value. Pointers
have shallow relational operators while <code class="computeroutput"><span class="identifier">optional</span></code>
has deep relational operators. Do not use <code class="computeroutput"><span class="keyword">operator</span><span class="special">&lt;</span></code> directly in generic code which expect
to be given either an <code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;</span></code> or a pointer; use <a href="../../../../../utility/OptionalPointee.html#less" target="_top"><code class="computeroutput"><span class="identifier">less_pointees</span><span class="special">()</span></code></a>
instead. <code class="computeroutput"><span class="identifier">T</span></code> need not be

View File

@ -54,7 +54,12 @@
</li>
<li class="listitem">
It is no longer possible to assign <code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">U</span><span class="special">&gt;</span></code> to <code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;</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>.
is not assignable or convertible to <code class="computeroutput"><span class="identifier">T</span></code>
(<a href="https://svn.boost.org/trac/boost/ticket/11087" target="_top">Trac #11087</a>).
</li>
<li class="listitem">
Value accessors now work correctly on rvalues of <code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&amp;&gt;</span></code> (<a href="https://svn.boost.org/trac/boost/ticket/10839" target="_top">Trac
#10839</a>).
</li>
</ul></div>
<h4>

View File

@ -138,7 +138,7 @@
</div>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"><p><small>Last revised: March 06, 2015 at 18:13:34 GMT</small></p></td>
<td align="left"><p><small>Last revised: March 09, 2015 at 09:53:44 GMT</small></p></td>
<td align="right"><div class="copyright-footer"></div></td>
</tr></table>
<hr>

View File

@ -39,10 +39,12 @@
<span class="keyword">namespace</span> <span class="identifier">boost</span> <span class="special">{</span>
<span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">&gt;</span>
<span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">&gt;</span>
<span class="keyword">class</span> <span class="identifier">optional</span>
<span class="special">{</span>
<span class="keyword">public</span> <span class="special">:</span>
<span class="keyword">public</span> <span class="special">:</span>
<span class="keyword">typedef</span> <span class="identifier">T</span> <span class="identifier">value_type</span><span class="special">;</span>
<span class="comment">// (If T is of reference type, the parameters and results by reference are by value)</span>