Minor docs fixes (operator=)

This commit is contained in:
Andrzej Krzemienski
2014-06-20 22:30:12 +02:00
parent 599c75a6d3
commit c7200c4aed
3 changed files with 52 additions and 37 deletions

View File

@ -600,18 +600,17 @@ __SPACE__
[: `optional& optional<T` ['(not a ref)]`>::operator= ( optional const& rhs ) ;`] [: `optional& optional<T` ['(not a ref)]`>::operator= ( optional const& rhs ) ;`]
* [*Effect:] Assigns another `optional` to an `optional`. * [*Requires:] `T` is __COPY_CONSTRUCTIBLE__ and `CopyAssignable`.
* [*Postconditions:] If `rhs` is initialized, `*this` is initialized and * [*Effects:]
its value is a ['copy] of the value of `rhs`; else `*this` is uninitialized. * If `!*this && !rhs` no effect, otherwise
* [*Throws:] Whatever `T::operator( T const&)` or `T::T( T const& )` throws. * if `bool(*this) && !rhs`, destroys the contained value by calling `val->T::~T()`, otherwise
* [*Notes:] If both `*this` and `rhs` are initially initialized, `T`'s * if `!*this && bool(rhs)`, initializes the contained value as if direct-initializing an object of type `T` with `*rhs`, otherwise
['assignment operator] is used. If `*this` is initially initialized but `rhs` is * (if `bool(*this) && bool(rhs)`) assigns `*rhs` to the contained value.
uninitialized, `T`'s [destructor] is called. If `*this` is initially uninitialized * [*Returns:] `*this`;
but `rhs` is initialized, `T`'s ['copy constructor] is called. * [*Postconditions:] `bool(rhs) == bool(*this)`.
* [*Exception Safety:] In the event of an exception, the initialization state of * [*Exception Safety:] If any exception is thrown, the initialization state of `*this` and `rhs` remains unchanged.
`*this` is unchanged and its value unspecified as far as optional is concerned If an exception is thrown during the call to `T`'s copy constructor, no effect.
(it is up to `T`'s `operator=()`). If `*this` is initially uninitialized and If an exception is thrown during the call to `T`'s copy assignment, the state of its contained value is as defined by the exception safety guarantee of `T`'s copy assignment.
`T`'s ['copy constructor] fails, `*this` is left properly uninitialized.
* [*Example:] * [*Example:]
`` ``
T v; T v;
@ -667,9 +666,10 @@ __SPACE__
* if `bool(*this) && !rhs`, destroys the contained value by calling `val->T::~T()`, otherwise * if `bool(*this) && !rhs`, destroys the contained value by calling `val->T::~T()`, otherwise
* if `!*this && bool(rhs)`, initializes the contained value as if direct-initializing an object of type `T` with `std::move(*rhs)`, otherwise * if `!*this && bool(rhs)`, initializes the contained value as if direct-initializing an object of type `T` with `std::move(*rhs)`, otherwise
* (if `bool(*this) && bool(rhs)`) assigns `std::move(*rhs)` to the contained value. * (if `bool(*this) && bool(rhs)`) assigns `std::move(*rhs)` to the contained value.
* [*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`.
* [*Exception Safety:] If any exception is thrown, the initialization state of `*this` and `rhs` remain unchanged. If an exception is * [*Exception Safety:] If any exception is thrown, the initialization state of `*this` and `rhs` remains unchanged. If an exception is
thrown during the call to `T`'s move constructor, the state of `*rhs` is determined by the exception safety guarantee thrown during the call to `T`'s move constructor, the state of `*rhs` is determined by the exception safety guarantee
of `T`'s move constructor. If an exception is thrown during the call to T's move-assignment, the state of `**this` and `*rhs` is determined by the exception safety guarantee of T's move assignment. of `T`'s move constructor. If an exception is thrown during the call to T's move-assignment, the state of `**this` and `*rhs` is determined by the exception safety guarantee of T's move assignment.
* [*Example:] * [*Example:]

View File

@ -804,36 +804,48 @@
</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 <code class="computeroutput"><span class="identifier">optional</span></code> to an <code class="computeroutput"><span class="identifier">optional</span></code>. <span class="bold"><strong>Requires:</strong></span> <code class="computeroutput"><span class="identifier">T</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">
<span class="bold"><strong>Postconditions:</strong></span> If <code class="computeroutput"><span class="identifier">rhs</span></code> <span class="bold"><strong>Effects:</strong></span>
is initialized, <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: circle; ">
is initialized and its value is a <span class="emphasis"><em>copy</em></span> of the value <li class="listitem">
of <code class="computeroutput"><span class="identifier">rhs</span></code>; else <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> If <code class="computeroutput"><span class="special">!*</span><span class="keyword">this</span>
is uninitialized. <span class="special">&amp;&amp;</span> <span class="special">!</span><span class="identifier">rhs</span></code> no effect, otherwise
</li>
<li class="listitem">
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">&amp;&amp;</span> <span class="special">!</span><span class="identifier">rhs</span></code>, destroys the contained value
by calling <code class="computeroutput"><span class="identifier">val</span><span class="special">-&gt;</span><span class="identifier">T</span><span class="special">::~</span><span class="identifier">T</span><span class="special">()</span></code>, otherwise
</li>
<li class="listitem">
if <code class="computeroutput"><span class="special">!*</span><span class="keyword">this</span>
<span class="special">&amp;&amp;</span> <span class="keyword">bool</span><span class="special">(</span><span class="identifier">rhs</span><span class="special">)</span></code>, 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>,
otherwise
</li>
<li class="listitem">
(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">&amp;&amp;</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.
</li>
</ul></div>
</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">T</span> <span class="keyword">const</span><span class="special">&amp;)</span></code> <span class="bold"><strong>Returns:</strong></span> <code class="computeroutput"><span class="special">*</span><span class="keyword">this</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">T</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="special">)</span></code>
throws.
</li> </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>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>.
are initially initialized, <code class="computeroutput"><span class="identifier">T</span></code>'s
<span class="emphasis"><em>assignment operator</em></span> 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 [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>copy constructor</em></span> is called.
</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> If any exception is
exception, the initialization state of <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> is unchanged and its value unspecified thrown, the initialization state of <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> and <code class="computeroutput"><span class="identifier">rhs</span></code>
as far as optional is concerned (it is up to <code class="computeroutput"><span class="identifier">T</span></code>'s remains unchanged. If an exception is thrown during the call to <code class="computeroutput"><span class="identifier">T</span></code>'s copy constructor, no effect. If
<code class="computeroutput"><span class="keyword">operator</span><span class="special">=()</span></code>). an exception is thrown during the call to <code class="computeroutput"><span class="identifier">T</span></code>'s
If <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> copy assignment, the state of its contained value is as defined by the
is initially uninitialized and <code class="computeroutput"><span class="identifier">T</span></code>'s exception safety guarantee of <code class="computeroutput"><span class="identifier">T</span></code>'s
<span class="emphasis"><em>copy constructor</em></span> fails, <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> is left properly uninitialized. copy assignment.
</li> </li>
<li class="listitem"> <li class="listitem">
<span class="bold"><strong>Example:</strong></span> <span class="bold"><strong>Example:</strong></span>
@ -931,6 +943,9 @@
</li> </li>
</ul></div> </ul></div>
</li> </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 class="listitem"> <li class="listitem">
<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>. <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>.
</li> </li>
@ -941,7 +956,7 @@
<li class="listitem"> <li class="listitem">
<span class="bold"><strong>Exception Safety:</strong></span> If any exception is <span class="bold"><strong>Exception Safety:</strong></span> If any exception is
thrown, the initialization state of <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> and <code class="computeroutput"><span class="identifier">rhs</span></code> thrown, the initialization state of <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> and <code class="computeroutput"><span class="identifier">rhs</span></code>
remain unchanged. If an exception is thrown during the call to <code class="computeroutput"><span class="identifier">T</span></code>'s move constructor, the state of remains unchanged. If an exception is thrown during the call to <code class="computeroutput"><span class="identifier">T</span></code>'s move constructor, the state of
<code class="computeroutput"><span class="special">*</span><span class="identifier">rhs</span></code> <code class="computeroutput"><span class="special">*</span><span class="identifier">rhs</span></code>
is determined by the exception safety guarantee of <code class="computeroutput"><span class="identifier">T</span></code>'s is determined by the exception safety guarantee of <code class="computeroutput"><span class="identifier">T</span></code>'s
move constructor. If an exception is thrown during the call to T's move-assignment, move constructor. If an exception is thrown during the call to T's move-assignment,

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