Doc typeo fixes + 1 test fix

This commit is contained in:
Andrzej Krzemienski
2014-09-12 11:57:44 +02:00
parent 55dc4c1dde
commit a913650322
8 changed files with 15 additions and 13 deletions

View File

@ -54,7 +54,7 @@ Distributed under the Boost Software License, Version 1.0.
Class template `optional` is a wrapper for representing 'optional' (or 'nullable') objects who may not (yet) contain a valid value. Optional objects offer full value semantics; they are good for passing by value and usage inside STL containers. This is a header-only library. Class template `optional` is a wrapper for representing 'optional' (or 'nullable') objects who may not (yet) contain a valid value. Optional objects offer full value semantics; they are good for passing by value and usage inside STL containers. This is a header-only library.
[heading Problem] [heading Problem]
Suppose we want to read a parameter form a config file which represents some integral value, let's call it `"MaxValue"`. It is possible that this parameter is not specified; such situation is no error. It is valid to not specify the parameter and in that case the program is supposed to behave slightly different. Also suppose that any possible value of type `int` is a valid value for `"MaxValue"`, so we cannot jut use `-1` to represent the absence of the parameter in the config file. Suppose we want to read a parameter form a config file which represents some integral value, let's call it `"MaxValue"`. It is possible that this parameter is not specified; such situation is no error. It is valid to not specify the parameter and in that case the program is supposed to behave slightly differently. Also, suppose that any possible value of type `int` is a valid value for `"MaxValue"`, so we cannot jut use `-1` to represent the absence of the parameter in the config file.
[heading Solution] [heading Solution]

View File

@ -14,7 +14,7 @@
[section Optional return values] [section Optional return values]
Let's write and use a converter function that converts an a `std::string` to an `int`. It is possible that for a given string (e.g. `"cat"`) there exist no value of type `int` capable of representing the conversion result. We do not consider such situation an error. We expect that the converter can be used only to check if the conversion is possible. A natural signature for this function can be: Let's write and use a converter function that converts a `std::string` to an `int`. It is possible that for a given string (e.g. `"cat"`) there exists no value of type `int` capable of representing the conversion result. We do not consider such situation an error. We expect that the converter can be used only to check if the conversion is possible. A natural signature for this function can be:
#include <boost/optional.hpp> #include <boost/optional.hpp>
boost::optional<int> convert(const std::string& text); boost::optional<int> convert(const std::string& text);
@ -91,7 +91,7 @@ We could write function `convert` in a slightly different manner, so that it has
return ans; return ans;
} }
The default constructor of `optional` creates an unitialized optional object. Unlike with `int`s you cannot have an `optional<int>` in an indeterminate state. Its state is always well defined. Instruction `ans = i` initializes the optional object. It uses the assignment from `int`. In general, for `optional<T>`, when an assignment from `T` is invoked, it can do two things. If the optional object is not initialized our case here), it initializes it with `T`'s copy constructor. If the optional object is already initialized, it assigns the new value to it using `T`'s copy assignment. The default constructor of `optional` creates an unitialized optional object. Unlike with `int`s you cannot have an `optional<int>` in an indeterminate state. Its state is always well defined. Instruction `ans = i` initializes the optional object. It uses the 'mixed' assignment from `int`. In general, for `optional<T>`, when an assignment from `T` is invoked, it can do two things. If the optional object is not initialized (our case here), it initializes the contained value using `T`'s copy constructor. If the optional object is already initialized, it assigns the new value to it using `T`'s copy assignment.
[endsect] [endsect]
[section Optional data members] [section Optional data members]

View File

@ -9,7 +9,7 @@ Type `optional<T>` is __SGI_EQUALITY_COMPARABLE__ whenever `T` is __SGI_EQUALITY
assert(oN != o0); assert(oN != o0);
assert(o1 != oN); assert(o1 != oN);
assert(o2 != o1); assert(o0 != o1);
assert(oN == oN); assert(oN == oN);
assert(o0 == o0); assert(o0 == o0);
@ -17,7 +17,7 @@ The converting constructor from `T` as well as from `boost::none` implies the ex
assert(oN != 0); assert(oN != 0);
assert(o1 != boost::none); assert(o1 != boost::none);
assert(o2 != 1); assert(o0 != 1);
assert(oN == boost::none); assert(oN == boost::none);
assert(o0 == 0); assert(o0 == 0);

View File

@ -44,10 +44,10 @@
return values</a> return values</a>
</h3></div></div></div> </h3></div></div></div>
<p> <p>
Let's write and use a converter function that converts an a <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span></code> Let's write and use a converter function that converts a <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span></code>
to an <code class="computeroutput"><span class="keyword">int</span></code>. It is possible that to an <code class="computeroutput"><span class="keyword">int</span></code>. It is possible that
for a given string (e.g. <code class="computeroutput"><span class="string">"cat"</span></code>) for a given string (e.g. <code class="computeroutput"><span class="string">"cat"</span></code>)
there exist no value of type <code class="computeroutput"><span class="keyword">int</span></code> there exists no value of type <code class="computeroutput"><span class="keyword">int</span></code>
capable of representing the conversion result. We do not consider such situation capable of representing the conversion result. We do not consider such situation
an error. We expect that the converter can be used only to check if the conversion an error. We expect that the converter can be used only to check if the conversion
is possible. A natural signature for this function can be: is possible. A natural signature for this function can be:

View File

@ -49,11 +49,11 @@
in an indeterminate state. Its state is always well defined. Instruction in an indeterminate state. Its state is always well defined. Instruction
<code class="computeroutput"><span class="identifier">ans</span> <span class="special">=</span> <code class="computeroutput"><span class="identifier">ans</span> <span class="special">=</span>
<span class="identifier">i</span></code> initializes the optional object. <span class="identifier">i</span></code> initializes the optional object.
It uses the assignment from <code class="computeroutput"><span class="keyword">int</span></code>. It uses the 'mixed' assignment from <code class="computeroutput"><span class="keyword">int</span></code>.
In general, for <code class="computeroutput"><span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;</span></code>, In general, for <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 an assignment from <code class="computeroutput"><span class="identifier">T</span></code> when an assignment from <code class="computeroutput"><span class="identifier">T</span></code>
is invoked, it can do two things. If the optional object is not initialized is invoked, it can do two things. If the optional object is not initialized
our case here), it initializes it with <code class="computeroutput"><span class="identifier">T</span></code>'s (our case here), it initializes the contained value using <code class="computeroutput"><span class="identifier">T</span></code>'s
copy constructor. If the optional object is already initialized, it assigns copy constructor. If the optional object is already initialized, it assigns
the new value to it using <code class="computeroutput"><span class="identifier">T</span></code>'s the new value to it using <code class="computeroutput"><span class="identifier">T</span></code>'s
copy assignment. copy assignment.

View File

@ -41,7 +41,7 @@
<span class="identifier">assert</span><span class="special">(</span><span class="identifier">oN</span> <span class="special">!=</span> <span class="identifier">o0</span><span class="special">);</span> <span class="identifier">assert</span><span class="special">(</span><span class="identifier">oN</span> <span class="special">!=</span> <span class="identifier">o0</span><span class="special">);</span>
<span class="identifier">assert</span><span class="special">(</span><span class="identifier">o1</span> <span class="special">!=</span> <span class="identifier">oN</span><span class="special">);</span> <span class="identifier">assert</span><span class="special">(</span><span class="identifier">o1</span> <span class="special">!=</span> <span class="identifier">oN</span><span class="special">);</span>
<span class="identifier">assert</span><span class="special">(</span><span class="identifier">o2</span> <span class="special">!=</span> <span class="identifier">o1</span><span class="special">);</span> <span class="identifier">assert</span><span class="special">(</span><span class="identifier">o0</span> <span class="special">!=</span> <span class="identifier">o1</span><span class="special">);</span>
<span class="identifier">assert</span><span class="special">(</span><span class="identifier">oN</span> <span class="special">==</span> <span class="identifier">oN</span><span class="special">);</span> <span class="identifier">assert</span><span class="special">(</span><span class="identifier">oN</span> <span class="special">==</span> <span class="identifier">oN</span><span class="special">);</span>
<span class="identifier">assert</span><span class="special">(</span><span class="identifier">o0</span> <span class="special">==</span> <span class="identifier">o0</span><span class="special">);</span> <span class="identifier">assert</span><span class="special">(</span><span class="identifier">o0</span> <span class="special">==</span> <span class="identifier">o0</span><span class="special">);</span>
</pre> </pre>
@ -55,7 +55,7 @@
</p> </p>
<pre class="programlisting"><span class="identifier">assert</span><span class="special">(</span><span class="identifier">oN</span> <span class="special">!=</span> <span class="number">0</span><span class="special">);</span> <pre class="programlisting"><span class="identifier">assert</span><span class="special">(</span><span class="identifier">oN</span> <span class="special">!=</span> <span class="number">0</span><span class="special">);</span>
<span class="identifier">assert</span><span class="special">(</span><span class="identifier">o1</span> <span class="special">!=</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">none</span><span class="special">);</span> <span class="identifier">assert</span><span class="special">(</span><span class="identifier">o1</span> <span class="special">!=</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">none</span><span class="special">);</span>
<span class="identifier">assert</span><span class="special">(</span><span class="identifier">o2</span> <span class="special">!=</span> <span class="number">1</span><span class="special">);</span> <span class="identifier">assert</span><span class="special">(</span><span class="identifier">o0</span> <span class="special">!=</span> <span class="number">1</span><span class="special">);</span>
<span class="identifier">assert</span><span class="special">(</span><span class="identifier">oN</span> <span class="special">==</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">none</span><span class="special">);</span> <span class="identifier">assert</span><span class="special">(</span><span class="identifier">oN</span> <span class="special">==</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">none</span><span class="special">);</span>
<span class="identifier">assert</span><span class="special">(</span><span class="identifier">o0</span> <span class="special">==</span> <span class="number">0</span><span class="special">);</span> <span class="identifier">assert</span><span class="special">(</span><span class="identifier">o0</span> <span class="special">==</span> <span class="number">0</span><span class="special">);</span>
</pre> </pre>

View File

@ -107,7 +107,7 @@
integral value, let's call it <code class="computeroutput"><span class="string">"MaxValue"</span></code>. integral value, let's call it <code class="computeroutput"><span class="string">"MaxValue"</span></code>.
It is possible that this parameter is not specified; such situation is no error. It is possible that this parameter is not specified; such situation is no error.
It is valid to not specify the parameter and in that case the program is supposed It is valid to not specify the parameter and in that case the program is supposed
to behave slightly different. Also suppose that any possible value of type to behave slightly differently. Also, suppose that any possible value of type
<code class="computeroutput"><span class="keyword">int</span></code> is a valid value for <code class="computeroutput"><span class="string">"MaxValue"</span></code>, so we cannot jut use <code class="computeroutput"><span class="special">-</span><span class="number">1</span></code> to represent <code class="computeroutput"><span class="keyword">int</span></code> is a valid value for <code class="computeroutput"><span class="string">"MaxValue"</span></code>, so we cannot jut use <code class="computeroutput"><span class="special">-</span><span class="number">1</span></code> to represent
the absence of the parameter in the config file. the absence of the parameter in the config file.
</p> </p>
@ -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: July 10, 2014 at 11:41:49 GMT</small></p></td> <td align="left"><p><small>Last revised: September 12, 2014 at 09:54: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>

View File

@ -1,7 +1,9 @@
struct A struct A
{ {
A(int) {} A(int) {}
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
A(A &&) {} A(A &&) {}
#endif
}; };
struct B struct B