From df01e9e4293003d52d4d17979318beb96ade7aab Mon Sep 17 00:00:00 2001 From: Daniel James Date: Mon, 18 Aug 2014 15:08:26 +0100 Subject: [PATCH 1/7] Add metadata file. --- meta/libraries.json | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 meta/libraries.json diff --git a/meta/libraries.json b/meta/libraries.json new file mode 100644 index 0000000..1652671 --- /dev/null +++ b/meta/libraries.json @@ -0,0 +1,14 @@ +{ + "key": "optional", + "name": "Optional", + "authors": [ + "Fernando Cacciola" + ], + "description": "Discriminated-union wrapper for optional values.", + "category": [ + "Miscellaneous" + ], + "maintainers": [ + "Fernando Cacciola " + ] +} From d4a4cdca1de5da4018f888054e506a0f8fc414a8 Mon Sep 17 00:00:00 2001 From: Kazutoshi SATODA Date: Wed, 27 Aug 2014 01:57:51 +0900 Subject: [PATCH 2/7] Supply to fix C++03 compile error on logic_error("...") This change makes the library usable (again) on C++03 standard library implementations where doesn't imply inclusion of , e.g. STLport. --- include/boost/optional/bad_optional_access.hpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/boost/optional/bad_optional_access.hpp b/include/boost/optional/bad_optional_access.hpp index bf5cae0..cabf43f 100644 --- a/include/boost/optional/bad_optional_access.hpp +++ b/include/boost/optional/bad_optional_access.hpp @@ -13,6 +13,9 @@ #define BOOST_BAD_OPTIONAL_ACCESS_22MAY2014_HPP #include +#if __cplusplus < 201103L +#include // to make converting-ctor std::string(char const*) visible +#endif namespace boost { From eef3bfe079d1e4aea9fcc54b9d9ca9c92ad8b6b6 Mon Sep 17 00:00:00 2001 From: Andrzej Krzemienski Date: Thu, 4 Sep 2014 23:47:46 +0200 Subject: [PATCH 3/7] Added a comaintainer to meta info --- meta/libraries.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/meta/libraries.json b/meta/libraries.json index 1652671..f40ada7 100644 --- a/meta/libraries.json +++ b/meta/libraries.json @@ -9,6 +9,7 @@ "Miscellaneous" ], "maintainers": [ - "Fernando Cacciola " + "Fernando Cacciola ", + "Andrzej Krzemienski " ] } From bda2001935e61d13c95371120561862a07b90a22 Mon Sep 17 00:00:00 2001 From: Andrzej Krzemienski Date: Fri, 5 Sep 2014 16:15:39 +0200 Subject: [PATCH 4/7] Testing MSVC bugs --- test/optional_test_COMPILER_CONVERSION_BUGS1.cpp | 16 ++++++++++++++++ test/optional_test_COMPILER_CONVERSION_BUGS2.cpp | 14 ++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 test/optional_test_COMPILER_CONVERSION_BUGS1.cpp create mode 100644 test/optional_test_COMPILER_CONVERSION_BUGS2.cpp diff --git a/test/optional_test_COMPILER_CONVERSION_BUGS1.cpp b/test/optional_test_COMPILER_CONVERSION_BUGS1.cpp new file mode 100644 index 0000000..63baf3f --- /dev/null +++ b/test/optional_test_COMPILER_CONVERSION_BUGS1.cpp @@ -0,0 +1,16 @@ +struct A +{ + A(int) {} + A(A &&) {} +}; + +struct B +{ + operator A() { return A(1); } + operator int() { return 0; } +}; + +int main() +{ + A t = B(); +} \ No newline at end of file diff --git a/test/optional_test_COMPILER_CONVERSION_BUGS2.cpp b/test/optional_test_COMPILER_CONVERSION_BUGS2.cpp new file mode 100644 index 0000000..9c6c699 --- /dev/null +++ b/test/optional_test_COMPILER_CONVERSION_BUGS2.cpp @@ -0,0 +1,14 @@ +struct A +{ + A(int) {} +}; + +struct B +{ + operator int() { return 0; } +}; + +int main() +{ + A t = B(); +} \ No newline at end of file From 55dc4c1ddeaa129ec5d27db85ca4299b3fd52a2d Mon Sep 17 00:00:00 2001 From: Andrzej Krzemienski Date: Fri, 5 Sep 2014 16:15:39 +0200 Subject: [PATCH 5/7] Testing MSVC bugs --- test/Jamfile.v2 | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index aeb0900..c9577d5 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -43,5 +43,7 @@ import testing ; [ compile-fail optional_test_ref_fail_assign_from_Urefref.cpp ] [ compile-fail optional_test_fail_explicit_convert_in_value_or.cpp ] [ compile-fail optional_test_fail_explicit_convert_in_value_or_call.cpp ] + [ run optional_test_COMPILER_CONVERSION_BUGS1.cpp ] + [ compile-fail optional_test_COMPILER_CONVERSION_BUGS2.cpp ] ; } From a913650322c03d21573f05dfb2748ce6245bda72 Mon Sep 17 00:00:00 2001 From: Andrzej Krzemienski Date: Fri, 12 Sep 2014 11:57:44 +0200 Subject: [PATCH 6/7] Doc typeo fixes + 1 test fix --- doc/00_optional.qbk | 2 +- doc/01_quick_start.qbk | 4 ++-- doc/13_relational_operators.qbk | 4 ++-- doc/html/boost_optional/quick_start.html | 4 ++-- .../quick_start/optional_automatic_variables.html | 4 ++-- doc/html/boost_optional/tutorial/relational_operators.html | 4 ++-- doc/html/index.html | 4 ++-- test/optional_test_COMPILER_CONVERSION_BUGS1.cpp | 2 ++ 8 files changed, 15 insertions(+), 13 deletions(-) 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 From 35d5e25672f235aad015a7d0c4ba08cc33e68d09 Mon Sep 17 00:00:00 2001 From: Andrzej Krzemienski Date: Wed, 8 Oct 2014 21:35:09 +0200 Subject: [PATCH 7/7] Removet compiler tests --- test/Jamfile.v2 | 2 -- ...optional_test_COMPILER_CONVERSION_BUGS1.cpp | 18 ------------------ ...optional_test_COMPILER_CONVERSION_BUGS2.cpp | 14 -------------- 3 files changed, 34 deletions(-) delete mode 100644 test/optional_test_COMPILER_CONVERSION_BUGS1.cpp delete mode 100644 test/optional_test_COMPILER_CONVERSION_BUGS2.cpp diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index c9577d5..aeb0900 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -43,7 +43,5 @@ import testing ; [ compile-fail optional_test_ref_fail_assign_from_Urefref.cpp ] [ compile-fail optional_test_fail_explicit_convert_in_value_or.cpp ] [ compile-fail optional_test_fail_explicit_convert_in_value_or_call.cpp ] - [ run optional_test_COMPILER_CONVERSION_BUGS1.cpp ] - [ compile-fail optional_test_COMPILER_CONVERSION_BUGS2.cpp ] ; } diff --git a/test/optional_test_COMPILER_CONVERSION_BUGS1.cpp b/test/optional_test_COMPILER_CONVERSION_BUGS1.cpp deleted file mode 100644 index c911a8b..0000000 --- a/test/optional_test_COMPILER_CONVERSION_BUGS1.cpp +++ /dev/null @@ -1,18 +0,0 @@ -struct A -{ - A(int) {} -#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES - A(A &&) {} -#endif -}; - -struct B -{ - operator A() { return A(1); } - operator int() { return 0; } -}; - -int main() -{ - A t = B(); -} \ No newline at end of file diff --git a/test/optional_test_COMPILER_CONVERSION_BUGS2.cpp b/test/optional_test_COMPILER_CONVERSION_BUGS2.cpp deleted file mode 100644 index 9c6c699..0000000 --- a/test/optional_test_COMPILER_CONVERSION_BUGS2.cpp +++ /dev/null @@ -1,14 +0,0 @@ -struct A -{ - A(int) {} -}; - -struct B -{ - operator int() { return 0; } -}; - -int main() -{ - A t = B(); -} \ No newline at end of file