diff --git a/doc/00_optional.qbk b/doc/00_optional.qbk index fcc308a..7cc8565 100644 --- a/doc/00_optional.qbk +++ b/doc/00_optional.qbk @@ -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. [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] diff --git a/doc/01_quick_start.qbk b/doc/01_quick_start.qbk index 4a94429..6bfc398 100644 --- a/doc/01_quick_start.qbk +++ b/doc/01_quick_start.qbk @@ -14,7 +14,7 @@ [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 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; } -The default constructor of `optional` creates an unitialized optional object. Unlike with `int`s you cannot have an `optional` 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`, 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` 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`, 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] [section Optional data members] diff --git a/doc/13_relational_operators.qbk b/doc/13_relational_operators.qbk index a16d53b..e36dcf5 100644 --- a/doc/13_relational_operators.qbk +++ b/doc/13_relational_operators.qbk @@ -9,7 +9,7 @@ Type `optional` is __SGI_EQUALITY_COMPARABLE__ whenever `T` is __SGI_EQUALITY assert(oN != o0); assert(o1 != oN); - assert(o2 != o1); + assert(o0 != o1); assert(oN == oN); 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(o1 != boost::none); - assert(o2 != 1); + assert(o0 != 1); assert(oN == boost::none); assert(o0 == 0); diff --git a/doc/html/boost_optional/quick_start.html b/doc/html/boost_optional/quick_start.html index 1c781f2..18ee7c2 100644 --- a/doc/html/boost_optional/quick_start.html +++ b/doc/html/boost_optional/quick_start.html @@ -44,10 +44,10 @@ return values

- Let's write and use a converter function that converts an a std::string + 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 exist no value of type int + 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: diff --git a/doc/html/boost_optional/quick_start/optional_automatic_variables.html b/doc/html/boost_optional/quick_start/optional_automatic_variables.html index bcf6b37..8d22f86 100644 --- a/doc/html/boost_optional/quick_start/optional_automatic_variables.html +++ b/doc/html/boost_optional/quick_start/optional_automatic_variables.html @@ -49,11 +49,11 @@ in an indeterminate state. Its state is always well defined. Instruction ans = i initializes the optional object. - It uses the assignment from int. + 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 it with T's + (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. diff --git a/doc/html/boost_optional/tutorial/relational_operators.html b/doc/html/boost_optional/tutorial/relational_operators.html index ecb8c4f..bc97e7b 100644 --- a/doc/html/boost_optional/tutorial/relational_operators.html +++ b/doc/html/boost_optional/tutorial/relational_operators.html @@ -41,7 +41,7 @@ assert(oN != o0); assert(o1 != oN); -assert(o2 != o1); +assert(o0 != o1); assert(oN == oN); assert(o0 == o0); @@ -55,7 +55,7 @@

assert(oN != 0);
 assert(o1 != boost::none);
-assert(o2 != 1);
+assert(o0 != 1);
 assert(oN == boost::none);
 assert(o0 == 0);
 
diff --git a/doc/html/index.html b/doc/html/index.html index 9b48711..3e4f671 100644 --- a/doc/html/index.html +++ b/doc/html/index.html @@ -107,7 +107,7 @@ 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 + 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.

@@ -133,7 +133,7 @@ - +

Last revised: July 10, 2014 at 11:41:49 GMT

Last revised: September 12, 2014 at 09:54:26 GMT


diff --git a/test/optional_test_COMPILER_CONVERSION_BUGS1.cpp b/test/optional_test_COMPILER_CONVERSION_BUGS1.cpp index 63baf3f..c911a8b 100644 --- a/test/optional_test_COMPILER_CONVERSION_BUGS1.cpp +++ b/test/optional_test_COMPILER_CONVERSION_BUGS1.cpp @@ -1,7 +1,9 @@ struct A { A(int) {} +#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES A(A &&) {} +#endif }; struct B