From 1d7fe0e770db50dd8e06821443d7246506398ac9 Mon Sep 17 00:00:00 2001 From: drivehappy Date: Tue, 21 Apr 2015 14:37:41 -0700 Subject: [PATCH 01/11] Removed unused parameters. --- include/boost/optional/optional.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/boost/optional/optional.hpp b/include/boost/optional/optional.hpp index afcb807..64ddac8 100644 --- a/include/boost/optional/optional.hpp +++ b/include/boost/optional/optional.hpp @@ -1251,7 +1251,7 @@ get_pointer ( optional& opt ) // The following declaration prevents a bug where operator safe-bool is used upon streaming optional object if you forget the IO header. template std::basic_ostream& -operator<<(std::basic_ostream& out, optional_detail::optional_tag const& v) +operator<<(std::basic_ostream&, optional_detail::optional_tag const&) { BOOST_STATIC_ASSERT_MSG(sizeof(CharType) == 0, "If you want to output boost::optional, include header "); } From 8ca74951b0b6046e5c839e7e1d07f0abb8a2b28f Mon Sep 17 00:00:00 2001 From: Andrzej Krzemienski Date: Fri, 15 May 2015 16:27:40 +0200 Subject: [PATCH 02/11] Added emplace(void) for older compilers --- doc/28_ref_optional_semantics.qbk | 4 +- .../detailed_semantics.html | 25 +++++++----- doc/html/index.html | 2 +- include/boost/optional/optional.hpp | 40 ++++++++++++++----- test/Jamfile.v2 | 19 ++++----- test/optional_test_emplace.cpp | 7 +++- test/optional_test_swap.cpp | 1 + 7 files changed, 65 insertions(+), 33 deletions(-) diff --git a/doc/28_ref_optional_semantics.qbk b/doc/28_ref_optional_semantics.qbk index 07f7a43..6ccea46 100644 --- a/doc/28_ref_optional_semantics.qbk +++ b/doc/28_ref_optional_semantics.qbk @@ -621,8 +621,10 @@ __SPACE__ of type `T` with `std::forward(args)...`. * [*Postconditions: ] `*this` is [_initialized]. * [*Throws:] Whatever the selected `T`'s constructor throws. -* [*Notes:] `T` need not be __MOVE_CONSTRUCTIBLE__ or `MoveAssignable`. On compilers that do not support variadic templates, the signature falls back to single-argument: `template void emplace(Arg&& arg)`. On compilers that do not support rvalue references, the signature falls back to two overloads: taking `const` and non-`const` lvalue reference. * [*Exception Safety:] If an exception is thrown during the initialization of `T`, `*this` is ['uninitialized]. +* [*Notes:] `T` need not be __MOVE_CONSTRUCTIBLE__ or `MoveAssignable`. + On compilers that do not support variadic templates, the signature falls back to two overloads:`template void emplace(Arg&& arg)` and `void emplace()`. + On compilers that do not support rvalue references, the signature falls back to three overloads: taking `const` and non-`const` lvalue reference, and third with empty function argument list. * [*Example:] `` T v; diff --git a/doc/html/boost_optional/reference/header__boost_optional_optional_hpp_/detailed_semantics.html b/doc/html/boost_optional/reference/header__boost_optional_optional_hpp_/detailed_semantics.html index a54a583..e2b974f 100644 --- a/doc/html/boost_optional/reference/header__boost_optional_optional_hpp_/detailed_semantics.html +++ b/doc/html/boost_optional/reference/header__boost_optional_optional_hpp_/detailed_semantics.html @@ -1336,23 +1336,26 @@
  • Throws: Whatever the selected T's constructor throws.
  • -
  • - Notes: T - need not be MoveConstructible - or MoveAssignable. - On compilers that do not support variadic templates, the signature - falls back to single-argument: template<class - Arg> - void emplace(Arg&& arg). On compilers that do not support - rvalue references, the signature falls back to two overloads: taking - const and non-const lvalue reference. -
  • Exception Safety: If an exception is thrown during the initialization of T, *this is uninitialized.
  • +
  • + Notes: T + need not be MoveConstructible + or MoveAssignable. + On compilers that do not support variadic templates, the signature + falls back to two overloads:template<class + Arg> + void emplace(Arg&& arg) and void + emplace(). + On compilers that do not support rvalue references, the signature falls + back to three overloads: taking const + and non-const lvalue reference, + and third with empty function argument list. +
  • Example:
    T v;
    diff --git a/doc/html/index.html b/doc/html/index.html
    index 891941d..2a66e9d 100644
    --- a/doc/html/index.html
    +++ b/doc/html/index.html
    @@ -146,7 +146,7 @@
     
     
     
    -
    +

    Last revised: March 13, 2015 at 21:52:15 GMT

    Last revised: May 15, 2015 at 14:16:05 GMT


    diff --git a/include/boost/optional/optional.hpp b/include/boost/optional/optional.hpp index 64ddac8..fd7cf73 100644 --- a/include/boost/optional/optional.hpp +++ b/include/boost/optional/optional.hpp @@ -18,12 +18,14 @@ #define BOOST_OPTIONAL_OPTIONAL_FLC_19NOV2002_HPP #include -#include #include #include #include +#include +#include #include +#include #include #include #include @@ -47,13 +49,7 @@ #include #include #include -#include #include -#include -#include -#include - - #include @@ -506,6 +502,13 @@ class optional_base : public optional_tag ::new (m_storage.address()) internal_type( boost::forward(arg) ); m_initialized = true ; } + + void emplace_assign () + { + destroy(); + ::new (m_storage.address()) internal_type(); + m_initialized = true ; + } #else template void emplace_assign ( const Arg& arg ) @@ -515,13 +518,20 @@ class optional_base : public optional_tag m_initialized = true ; } - template + template void emplace_assign ( Arg& arg ) { destroy(); ::new (m_storage.address()) internal_type( arg ); m_initialized = true ; } + + void emplace_assign () + { + destroy(); + ::new (m_storage.address()) internal_type(); + m_initialized = true ; + } #endif #ifndef BOOST_OPTIONAL_NO_INPLACE_FACTORY_SUPPORT @@ -976,6 +986,11 @@ class optional : public optional_detail::optional_base { this->emplace_assign( boost::forward(arg) ); } + + void emplace () + { + this->emplace_assign(); + } #else template void emplace ( const Arg& arg ) @@ -988,6 +1003,11 @@ class optional : public optional_detail::optional_base { this->emplace_assign( arg ); } + + void emplace () + { + this->emplace_assign(); + } #endif void swap( optional & arg ) @@ -1448,9 +1468,9 @@ struct swap_selector return; if( !hasX ) - x = boost::in_place(); + x.emplace(); else if ( !hasY ) - y = boost::in_place(); + y.emplace(); // Boost.Utility.Swap will take care of ADL and workarounds for broken compilers boost::swap(x.get(),y.get()); diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index d654545..ea9e81b 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -1,15 +1,16 @@ -# Boost.Optional Library test Jamfile +# Boost.Optional Library test Jamfile # -# Copyright (C) 2003, Fernando Luis Cacciola Carballal. +# Copyright (C) 2003, Fernando Luis Cacciola Carballal. +# Copyright (C) 2014, 2015 Andrzej Krzemienski # -# This material is provided "as is", with absolutely no warranty expressed -# or implied. Any use is at your own risk. +# Use, modification, and distribution is subject to the Boost Software +# License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +# http://www.boost.org/LICENSE_1_0.txt) # -# Permission to use or copy this software for any purpose is hereby granted -# without fee, provided the above notices are retained on all copies. -# Permission to modify the code and to distribute modified code is granted, -# provided the above notices are retained, and a notice that the code was -# modified is included with the above copyright notice. +# See http://www.boost.org/libs/optional for documentation. +# +# You are welcome to contact the author at: +# akrzemi1@gmail.com # import testing ; diff --git a/test/optional_test_emplace.cpp b/test/optional_test_emplace.cpp index 117f26c..9e7ed8a 100644 --- a/test/optional_test_emplace.cpp +++ b/test/optional_test_emplace.cpp @@ -145,11 +145,16 @@ void test_clear_on_throw() void test_no_assignment_on_emplacement() { - optional os; + optional os, ot; BOOST_TEST(!os); os.emplace("wow"); BOOST_TEST(os); BOOST_TEST_EQ(*os, "wow"); + + BOOST_TEST(!ot); + ot.emplace(); + BOOST_TEST(ot); + BOOST_TEST_EQ(*ot, ""); } int main() diff --git a/test/optional_test_swap.cpp b/test/optional_test_swap.cpp index b6802b1..dac7ae1 100644 --- a/test/optional_test_swap.cpp +++ b/test/optional_test_swap.cpp @@ -15,6 +15,7 @@ // #include "boost/optional/optional.hpp" +#include "boost/utility/in_place_factory.hpp" #ifdef __BORLANDC__ #pragma hdrstop From ff90f939edf33c3a96e1851c8c2df4ec3646ca24 Mon Sep 17 00:00:00 2001 From: Andrzej Krzemienski Date: Sat, 16 May 2015 00:06:55 +0200 Subject: [PATCH 03/11] Added 1 more test for emplace() --- test/optional_test_emplace.cpp | 48 ++++++++++++++++++++++++++++------ 1 file changed, 40 insertions(+), 8 deletions(-) diff --git a/test/optional_test_emplace.cpp b/test/optional_test_emplace.cpp index 9e7ed8a..0aa6674 100644 --- a/test/optional_test_emplace.cpp +++ b/test/optional_test_emplace.cpp @@ -157,18 +157,50 @@ void test_no_assignment_on_emplacement() BOOST_TEST_EQ(*ot, ""); } +namespace no_rvalue_refs { +class Guard +{ +public: + int which_ctor; + Guard () : which_ctor(0) { } + Guard (std::string const&) : which_ctor(5) { } + Guard (std::string &) : which_ctor(6) { } +private: + Guard(Guard const&); + void operator=(Guard const&); +}; + +void test_emplace() +{ + const std::string cs; + std::string ms; + optional o; + + o.emplace(); + BOOST_TEST(o); + BOOST_TEST(0 == o->which_ctor); + + o.emplace(cs); + BOOST_TEST(o); + BOOST_TEST(5 == o->which_ctor); + + o.emplace(ms); + BOOST_TEST(o); + BOOST_TEST(6 == o->which_ctor); +} +} + int main() { #if (!defined BOOST_NO_CXX11_RVALUE_REFERENCES) && (!defined BOOST_NO_CXX11_VARIADIC_TEMPLATES) - test_emplace(); + test_emplace(); #endif #if (!defined BOOST_NO_CXX11_RVALUE_REFERENCES) - test_no_moves_on_emplacement(); + test_no_moves_on_emplacement(); #endif - test_clear_on_throw(); - test_no_assignment_on_emplacement(); - - return boost::report_errors(); + test_clear_on_throw(); + test_no_assignment_on_emplacement(); + no_rvalue_refs::test_emplace(); + + return boost::report_errors(); } - - From 4e7405a2339b0534c7975c850714174ba3fcfca1 Mon Sep 17 00:00:00 2001 From: Andrzej Krzemienski Date: Mon, 18 May 2015 16:51:12 +0200 Subject: [PATCH 04/11] Sane swap() for rvalue-aware compilers When we detect that compiler supports rvalue references, we implement swap() in term of moves (as intuition suggests). Otherwise we fall back to old tricks with default constructor+swap --- include/boost/optional/optional.hpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/include/boost/optional/optional.hpp b/include/boost/optional/optional.hpp index fd7cf73..f059e2e 100644 --- a/include/boost/optional/optional.hpp +++ b/include/boost/optional/optional.hpp @@ -1543,9 +1543,18 @@ struct swap_selector } // namespace optional_detail +#if (!defined BOOST_NO_CXX11_RVALUE_REFERENCES) && (!defined BOOST_CONFIG_RESTORE_OBSOLETE_SWAP_IMPLEMENTATION) + +template +struct optional_swap_should_use_default_constructor : boost::false_type {} ; + +#else + template struct optional_swap_should_use_default_constructor : has_nothrow_default_constructor {} ; +#endif //BOOST_NO_CXX11_RVALUE_REFERENCES + template inline void swap ( optional& x, optional& y ) //BOOST_NOEXCEPT_IF(::boost::is_nothrow_move_constructible::value && BOOST_NOEXCEPT_EXPR(boost::swap(*x, *y))) { From 95a073f0614bdb13dd5a9b2c1c20c861581c828e Mon Sep 17 00:00:00 2001 From: Andrzej Krzemienski Date: Mon, 18 May 2015 22:09:56 +0200 Subject: [PATCH 05/11] using macro BOOST_NO_CXX11_NOEXCEPT --- test/Jamfile.v2 | 1 + test/ak_test_vc14_noexcept.cpp | 31 ++++++++++++++++++++++++++++ test/optional_test_noexcept_move.cpp | 4 ++-- 3 files changed, 34 insertions(+), 2 deletions(-) create mode 100644 test/ak_test_vc14_noexcept.cpp diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index ea9e81b..1bf1968 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -18,6 +18,7 @@ import testing ; { test-suite optional : [ run optional_test.cpp ] + [ run ak_test_vc14_noexcept.cpp ] [ run optional_test_swap.cpp ] [ run optional_test_conversions_from_U.cpp ] [ run optional_test_tie.cpp ] diff --git a/test/ak_test_vc14_noexcept.cpp b/test/ak_test_vc14_noexcept.cpp new file mode 100644 index 0000000..f6ab367 --- /dev/null +++ b/test/ak_test_vc14_noexcept.cpp @@ -0,0 +1,31 @@ +// Copyright (C) 2014 Andrzej Krzemienski. +// +// Use, modification, and distribution is subject to the Boost Software +// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// +// See http://www.boost.org/lib/optional for documentation. +// +// You are welcome to contact the author at: +// akrzemi1@gmail.com + +#include "boost/static_assert.hpp" +#include "boost/optional/optional.hpp" + +#ifdef __BORLANDC__ +#pragma hdrstop +#endif + + +using boost::optional; + +#if defined BOOST_NO_CXX11_NOEXCEPT +BOOST_STATIC_ASSERT_MSG(false, "absent noexcept"); +#endif + +int main() +{ + return 0; +} + + diff --git a/test/optional_test_noexcept_move.cpp b/test/optional_test_noexcept_move.cpp index b0c2220..9ce927f 100644 --- a/test/optional_test_noexcept_move.cpp +++ b/test/optional_test_noexcept_move.cpp @@ -21,7 +21,7 @@ using boost::optional; #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES -#ifndef BOOST_NO_NOEXCEPT +#ifndef BOOST_NO_CXX11_NOEXCEPT // these 4 classes have different noexcept signatures in move operations struct NothrowBoth { @@ -105,7 +105,7 @@ void test_noexcept_optional_with_operator() // compile-time test BOOST_STATIC_ASSERT(!BOOST_NOEXCEPT_EXPR( onx0 = ONx0() )); } -#endif // !defned BOOST_NO_NOEXCEPT +#endif // !defned BOOST_NO_CXX11_NOEXCEPT #endif // !defined BOOST_NO_CXX11_RVALUE_REFERENCES int main() From 5ece1f224ab2b8ee9849f64f1246fdafc17fa6fc Mon Sep 17 00:00:00 2001 From: Andrzej Krzemienski Date: Mon, 18 May 2015 22:40:15 +0200 Subject: [PATCH 06/11] Added meta test for buggy type trait --- test/Jamfile.v2 | 1 + test/ak_test_trait_noexcept_default.cpp | 26 +++++++++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 test/ak_test_trait_noexcept_default.cpp diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 1bf1968..546e823 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -19,6 +19,7 @@ import testing ; test-suite optional : [ run optional_test.cpp ] [ run ak_test_vc14_noexcept.cpp ] + [ run ak_test_trait_noexcept_default.cpp ] [ run optional_test_swap.cpp ] [ run optional_test_conversions_from_U.cpp ] [ run optional_test_tie.cpp ] diff --git a/test/ak_test_trait_noexcept_default.cpp b/test/ak_test_trait_noexcept_default.cpp new file mode 100644 index 0000000..7dd8ac2 --- /dev/null +++ b/test/ak_test_trait_noexcept_default.cpp @@ -0,0 +1,26 @@ +#include +#include +#include + +namespace some_namespace +{ + class base_class + { + public: + base_class & operator=(const base_class &){ throw int(); } + virtual ~base_class() {} + }; + + class class_without_default_ctor : public base_class + { + public: + char data; + explicit class_without_default_ctor(char arg) : data(arg) {} + }; +} + +int main() +{ + BOOST_TEST_TRAIT_FALSE((boost::has_nothrow_default_constructor)); + return boost::report_errors(); +} From 4be4646ddd23b0df12f0e61dc444b26aa20518bd Mon Sep 17 00:00:00 2001 From: Andrzej Krzemienski Date: Tue, 19 May 2015 23:14:15 +0200 Subject: [PATCH 07/11] Added mock test for rvalue refs --- test/Jamfile.v2 | 1 + test/ak_test_rvalue_references.cpp | 31 ++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 test/ak_test_rvalue_references.cpp diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 546e823..ca3f86d 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -20,6 +20,7 @@ import testing ; [ run optional_test.cpp ] [ run ak_test_vc14_noexcept.cpp ] [ run ak_test_trait_noexcept_default.cpp ] + [ run ak_test_rvalue_references.cpp ] [ run optional_test_swap.cpp ] [ run optional_test_conversions_from_U.cpp ] [ run optional_test_tie.cpp ] diff --git a/test/ak_test_rvalue_references.cpp b/test/ak_test_rvalue_references.cpp new file mode 100644 index 0000000..29a2993 --- /dev/null +++ b/test/ak_test_rvalue_references.cpp @@ -0,0 +1,31 @@ +// Copyright (C) 2014 Andrzej Krzemienski. +// +// Use, modification, and distribution is subject to the Boost Software +// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// +// See http://www.boost.org/lib/optional for documentation. +// +// You are welcome to contact the author at: +// akrzemi1@gmail.com + +#include "boost/static_assert.hpp" +#include "boost/optional/optional.hpp" + +#ifdef __BORLANDC__ +#pragma hdrstop +#endif + + +using boost::optional; + +#if defined BOOST_NO_CXX11_RVALUE_REFERENCES +BOOST_STATIC_ASSERT_MSG(false, "absent rvalue refs"); +#endif + +int main() +{ + return 0; +} + + From 9b1894a2f3ff9b3767515bee0cfc0616aedd8733 Mon Sep 17 00:00:00 2001 From: Andrzej Krzemienski Date: Wed, 27 May 2015 17:06:31 +0200 Subject: [PATCH 08/11] Doc: no headers in tables in semantics --- doc/28_ref_optional_semantics.qbk | 39 ++-- .../detailed_semantics.html | 195 +++++++++--------- doc/html/index.html | 2 +- 3 files changed, 118 insertions(+), 118 deletions(-) diff --git a/doc/28_ref_optional_semantics.qbk b/doc/28_ref_optional_semantics.qbk index 6ccea46..791eb99 100644 --- a/doc/28_ref_optional_semantics.qbk +++ b/doc/28_ref_optional_semantics.qbk @@ -463,10 +463,11 @@ __SPACE__ * [*Requires:] `T` is __COPY_CONSTRUCTIBLE__ and `CopyAssignable`. * [*Effects:] -[table - [[][`*this` contains a value][`*this` does not contain a value]] - [[`rhs` contains a value][assigns `*rhs` to the contained value][initializes the contained value as if direct-initializing an object of type `T` with `*rhs`]] - [[`rhs` does not contain a value][destroys the contained value by calling `val->T::~T()`][no effect]] +[table + [] + [[][[*`*this` contains a value]][[*`*this` does not contain a value]]] + [[[*`rhs` contains a value]][assigns `*rhs` to the contained value][initializes the contained value as if direct-initializing an object of type `T` with `*rhs`]] + [[[*`rhs` does not contain a value]][destroys the contained value by calling `val->T::~T()`][no effect]] ] * [*Returns:] `*this`; * [*Postconditions:] `bool(rhs) == bool(*this)`. @@ -525,9 +526,10 @@ __SPACE__ * [*Requires:] `T` is __MOVE_CONSTRUCTIBLE__ and `MoveAssignable`. * [*Effects:] [table - [[][`*this` contains a value][`*this` does not contain a value]] - [[`rhs` contains a value][assigns `std::move(*rhs)` to the contained value][initializes the contained value as if direct-initializing an object of type `T` with `std::move(*rhs)`]] - [[`rhs` does not contain a value][destroys the contained value by calling `val->T::~T()`][no effect]] + [] + [[][[*`*this` contains a value]][[*`*this` does not contain a value]]] + [[[*`rhs` contains a value]][assigns `std::move(*rhs)` to the contained value][initializes the contained value as if direct-initializing an object of type `T` with `std::move(*rhs)`]] + [[[*`rhs` does not contain a value]][destroys the contained value by calling `val->T::~T()`][no effect]] ] * [*Returns:] `*this`; * [*Postconditions:] `bool(rhs) == bool(*this)`. @@ -561,9 +563,10 @@ __SPACE__ * [*Effect:] [table - [[][`*this` contains a value][`*this` does not contain a value]] - [[`rhs` contains a value][assigns `*rhs` to the contained value][initializes the contained value as if direct-initializing an object of type `T` with `*rhs`]] - [[`rhs` does not contain a value][destroys the contained value by calling `val->T::~T()`][no effect]] + [] + [[][[*`*this` contains a value]][[*`*this` does not contain a value]]] + [[[*`rhs` contains a value]][assigns `*rhs` to the contained value][initializes the contained value as if direct-initializing an object of type `T` with `*rhs`]] + [[[*`rhs` does not contain a value]][destroys the contained value by calling `val->T::~T()`][no effect]] ] * [*Returns:] `*this`. * [*Postconditions:] `bool(rhs) == bool(*this)`. @@ -587,10 +590,11 @@ __SPACE__ [: `template optional& optional::operator= ( optional&& rhs ) ;`] * [*Effect:] -[table - [[][`*this` contains a value][`*this` does not contain a value]] - [[`rhs` contains a value][assigns `std::move(*rhs)` to the contained value][initializes the contained value as if direct-initializing an object of type `T` with `std::move(*rhs)`]] - [[`rhs` does not contain a value][destroys the contained value by calling `val->T::~T()`][no effect]] +[table + [] + [[][[*`*this` contains a value]][[*`*this` does not contain a value]]] + [[[*`rhs` contains a value]][assigns `std::move(*rhs)` to the contained value][initializes the contained value as if direct-initializing an object of type `T` with `std::move(*rhs)`]] + [[[*`rhs` does not contain a value]][destroys the contained value by calling `val->T::~T()`][no effect]] ] * [*Returns:] `*this`. * [*Postconditions:] `bool(rhs) == bool(*this)`. @@ -1113,9 +1117,10 @@ __SPACE__ * [*Requires:] Lvalues of type `T` shall be swappable and `T` shall be __MOVE_CONSTRUCTIBLE__. * [*Effects:] [table - [[][`*this` contains a value][`*this` does not contain a value]] - [[`rhs` contains a value][calls `swap(*(*this), *rhs)`][initializes the contained value of `*this` as if direct-initializing an object of type `T` with the expression `std::move(*rhs)`, followed by `rhs.val->T::~T()`, `*this` contains a value and `rhs` does not contain a value]] - [[`rhs` does not contain a value][initializes the contained value of `rhs` as if direct-initializing an object of type `T` with the expression `std::move(*(*this))`, followed by `val->T::~T()`, `*this` does not contain a value and `rhs` contains a value][no effect]] + [] + [[][[*`*this` contains a value]][[*`*this` does not contain a value]]] + [[[*`rhs` contains a value]][calls `swap(*(*this), *rhs)`][initializes the contained value of `*this` as if direct-initializing an object of type `T` with the expression `std::move(*rhs)`, followed by `rhs.val->T::~T()`, `*this` contains a value and `rhs` does not contain a value]] + [[[*`rhs` does not contain a value]][initializes the contained value of `rhs` as if direct-initializing an object of type `T` with the expression `std::move(*(*this))`, followed by `val->T::~T()`, `*this` does not contain a value and `rhs` contains a value][no effect]] ] * [*Postconditions:] The states of `x` and `y` interchanged. * [*Throws:] If both are initialized, whatever `swap(T&,T&)` throws. If only diff --git a/doc/html/boost_optional/reference/header__boost_optional_optional_hpp_/detailed_semantics.html b/doc/html/boost_optional/reference/header__boost_optional_optional_hpp_/detailed_semantics.html index e2b974f..47b4d4c 100644 --- a/doc/html/boost_optional/reference/header__boost_optional_optional_hpp_/detailed_semantics.html +++ b/doc/html/boost_optional/reference/header__boost_optional_optional_hpp_/detailed_semantics.html @@ -838,28 +838,27 @@ - - - - -

    - *this - contains a value -

    - - -

    - *this - does not contain a value -

    - - + + +

    - rhs contains - a value + *this contains a value +

    + + +

    + *this does not contain a value +

    + + + + +

    + rhs + contains a value

    @@ -879,8 +878,8 @@

    - rhs does - not contain a value + rhs + does not contain a value

    @@ -995,28 +994,27 @@ - - - - -

    - *this - contains a value -

    - - -

    - *this - does not contain a value -

    - - + + +

    - rhs contains - a value + *this contains a value +

    + + +

    + *this does not contain a value +

    + + + + +

    + rhs + contains a value

    @@ -1035,8 +1033,8 @@

    - rhs does - not contain a value + rhs + does not contain a value

    @@ -1117,28 +1115,27 @@ - - - - -

    - *this - contains a value -

    - - -

    - *this - does not contain a value -

    - - + + +

    - rhs contains - a value + *this contains a value +

    + + +

    + *this does not contain a value +

    + + + + +

    + rhs + contains a value

    @@ -1158,8 +1155,8 @@

    - rhs does - not contain a value + rhs + does not contain a value

    @@ -1222,28 +1219,27 @@ - - - - -

    - *this - contains a value -

    - - -

    - *this - does not contain a value -

    - - + + +

    - rhs contains - a value + *this contains a value +

    + + +

    + *this does not contain a value +

    + + + + +

    + rhs + contains a value

    @@ -1262,8 +1258,8 @@

    - rhs does - not contain a value + rhs + does not contain a value

    @@ -2274,28 +2270,27 @@ - - - - -

    - *this - contains a value -

    - - -

    - *this - does not contain a value -

    - - + + +

    - rhs contains - a value + *this contains a value +

    + + +

    + *this does not contain a value +

    + + + + +

    + rhs + contains a value

    @@ -2317,8 +2312,8 @@

    - rhs does - not contain a value + rhs + does not contain a value

    diff --git a/doc/html/index.html b/doc/html/index.html index 2a66e9d..6af5b8e 100644 --- a/doc/html/index.html +++ b/doc/html/index.html @@ -146,7 +146,7 @@ - +

    Last revised: May 15, 2015 at 14:16:05 GMT

    Last revised: May 27, 2015 at 12:41:23 GMT


    From b43ce289c221b70ae561e468632633840ddc9018 Mon Sep 17 00:00:00 2001 From: Andrzej Krzemienski Date: Wed, 3 Jun 2015 18:22:41 +0200 Subject: [PATCH 09/11] Fixed no-return warning --- include/boost/optional/optional.hpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/include/boost/optional/optional.hpp b/include/boost/optional/optional.hpp index f059e2e..9def94e 100644 --- a/include/boost/optional/optional.hpp +++ b/include/boost/optional/optional.hpp @@ -1271,9 +1271,10 @@ get_pointer ( optional& opt ) // The following declaration prevents a bug where operator safe-bool is used upon streaming optional object if you forget the IO header. template std::basic_ostream& -operator<<(std::basic_ostream&, optional_detail::optional_tag const&) +operator<<(std::basic_ostream& os, optional_detail::optional_tag const&) { - BOOST_STATIC_ASSERT_MSG(sizeof(CharType) == 0, "If you want to output boost::optional, include header "); + BOOST_STATIC_ASSERT_MSG(sizeof(CharType) == 0, "If you want to output boost::optional, include header "); + return os; } // optional's relational operators ( ==, !=, <, >, <=, >= ) have deep-semantics (compare values). From 4beeba5420d73c70a838f3f0bbd7e9006e997e5a Mon Sep 17 00:00:00 2001 From: Andrzej Krzemienski Date: Mon, 8 Jun 2015 23:37:40 +0200 Subject: [PATCH 10/11] msvc noexcept test improvement --- test/ak_test_vc14_noexcept.cpp | 39 ++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/test/ak_test_vc14_noexcept.cpp b/test/ak_test_vc14_noexcept.cpp index f6ab367..03aa15a 100644 --- a/test/ak_test_vc14_noexcept.cpp +++ b/test/ak_test_vc14_noexcept.cpp @@ -23,6 +23,45 @@ using boost::optional; BOOST_STATIC_ASSERT_MSG(false, "absent noexcept"); #endif +// these 4 classes have different noexcept signatures in move operations +struct NothrowBoth { + NothrowBoth() BOOST_NOEXCEPT {}; + NothrowBoth(NothrowBoth&&) BOOST_NOEXCEPT_IF(true) {}; + void operator=(NothrowBoth&&) BOOST_NOEXCEPT_IF(true) {}; +}; +struct NothrowCtor { + NothrowCtor(NothrowCtor&&) BOOST_NOEXCEPT_IF(true) {}; + void operator=(NothrowCtor&&) BOOST_NOEXCEPT_IF(false) {}; +}; +struct NothrowAssign { + NothrowAssign(NothrowAssign&&) BOOST_NOEXCEPT_IF(false) {}; + void operator=(NothrowAssign&&) BOOST_NOEXCEPT_IF(true) {}; +}; +struct NothrowNone { + NothrowNone(NothrowNone&&) BOOST_NOEXCEPT_IF(false) {}; + void operator=(NothrowNone&&) BOOST_NOEXCEPT_IF(false) {}; +}; + +NothrowBoth ntb; +BOOST_STATIC_ASSERT( BOOST_NOEXCEPT_EXPR( ntb = NothrowBoth() )); + +void test_noexcept_as_defined() // this is a compile-time test +{ + BOOST_STATIC_ASSERT(::boost::is_nothrow_move_constructible::value); + BOOST_STATIC_ASSERT(::boost::is_nothrow_move_assignable::value); + + BOOST_STATIC_ASSERT(::boost::is_nothrow_move_constructible::value); + BOOST_STATIC_ASSERT(!::boost::is_nothrow_move_assignable::value); + + BOOST_STATIC_ASSERT(!::boost::is_nothrow_move_constructible::value); + BOOST_STATIC_ASSERT(::boost::is_nothrow_move_assignable::value); + + BOOST_STATIC_ASSERT(!::boost::is_nothrow_move_constructible::value); + BOOST_STATIC_ASSERT(!::boost::is_nothrow_move_assignable::value); +} + + + int main() { return 0; From 593710e961448f2714896ed21e7272eadf6d16d3 Mon Sep 17 00:00:00 2001 From: Andrzej Krzemienski Date: Wed, 8 Jul 2015 23:54:20 +0200 Subject: [PATCH 11/11] doc: added relnotes for 1.59 --- doc/91_relnotes.qbk | 8 ++- doc/html/boost_optional/relnotes.html | 17 ++++-- doc/html/index.html | 2 +- test/Jamfile.v2 | 3 -- test/ak_test_rvalue_references.cpp | 31 ----------- test/ak_test_trait_noexcept_default.cpp | 26 --------- test/ak_test_vc14_noexcept.cpp | 70 ------------------------- 7 files changed, 20 insertions(+), 137 deletions(-) delete mode 100644 test/ak_test_rvalue_references.cpp delete mode 100644 test/ak_test_trait_noexcept_default.cpp delete mode 100644 test/ak_test_vc14_noexcept.cpp diff --git a/doc/91_relnotes.qbk b/doc/91_relnotes.qbk index e75fef7..eb2b310 100644 --- a/doc/91_relnotes.qbk +++ b/doc/91_relnotes.qbk @@ -11,12 +11,16 @@ [section:relnotes Release Notes] +[heading Boost Release 1.59] + +* For C++03 compilers, added 0-argument overload for member function `emplace()`, and therewith removed the dependency on ``. + [heading Boost Release 1.58] * `boost::none_t` is no longer convertible from literal `0`. This avoids a bug where `optional> oi = 0;` would initialize an optional object with no contained value. -* 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] +* 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] +* 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` to `optional` 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` ([@https://svn.boost.org/trac/boost/ticket/10839 Trac #10839]). diff --git a/doc/html/boost_optional/relnotes.html b/doc/html/boost_optional/relnotes.html index 3fb495b..445eaa8 100644 --- a/doc/html/boost_optional/relnotes.html +++ b/doc/html/boost_optional/relnotes.html @@ -28,6 +28,15 @@

    + Boost + Release 1.59 +

    +
    • + For C++03 compilers, added 0-argument overload for member function emplace(), + and therewith removed the dependency on <boost/utility/in_place_factory.hpp>. +
    +

    + Boost Release 1.58

    @@ -42,7 +51,7 @@ Improved the trick that prevents streaming out optional without header optional_io.hpp by using safe-bool idiom. This addresses Trac - #10825 + #10825.
  • IOStream operators are now mentioned in documentation. @@ -50,7 +59,7 @@
  • Added a way to manually disable move semantics: just define macro BOOST_OPTIONAL_CONFIG_NO_RVALUE_REFERENCES. This can be used to work around Trac - #10399 + #10399.
  • It is no longer possible to assign optional<U> to optional<T> when U @@ -63,7 +72,7 @@
  • - + Boost Release 1.57

    @@ -73,7 +82,7 @@ to fix C++03 compile error on logic_error("...")".

    - + Boost Release 1.56

    diff --git a/doc/html/index.html b/doc/html/index.html index 6af5b8e..2b0d9fd 100644 --- a/doc/html/index.html +++ b/doc/html/index.html @@ -146,7 +146,7 @@ - +

    Last revised: May 27, 2015 at 12:41:23 GMT

    Last revised: July 08, 2015 at 21:39:55 GMT


    diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index ca3f86d..ea9e81b 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -18,9 +18,6 @@ import testing ; { test-suite optional : [ run optional_test.cpp ] - [ run ak_test_vc14_noexcept.cpp ] - [ run ak_test_trait_noexcept_default.cpp ] - [ run ak_test_rvalue_references.cpp ] [ run optional_test_swap.cpp ] [ run optional_test_conversions_from_U.cpp ] [ run optional_test_tie.cpp ] diff --git a/test/ak_test_rvalue_references.cpp b/test/ak_test_rvalue_references.cpp deleted file mode 100644 index 29a2993..0000000 --- a/test/ak_test_rvalue_references.cpp +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright (C) 2014 Andrzej Krzemienski. -// -// Use, modification, and distribution is subject to the Boost Software -// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) -// -// See http://www.boost.org/lib/optional for documentation. -// -// You are welcome to contact the author at: -// akrzemi1@gmail.com - -#include "boost/static_assert.hpp" -#include "boost/optional/optional.hpp" - -#ifdef __BORLANDC__ -#pragma hdrstop -#endif - - -using boost::optional; - -#if defined BOOST_NO_CXX11_RVALUE_REFERENCES -BOOST_STATIC_ASSERT_MSG(false, "absent rvalue refs"); -#endif - -int main() -{ - return 0; -} - - diff --git a/test/ak_test_trait_noexcept_default.cpp b/test/ak_test_trait_noexcept_default.cpp deleted file mode 100644 index 7dd8ac2..0000000 --- a/test/ak_test_trait_noexcept_default.cpp +++ /dev/null @@ -1,26 +0,0 @@ -#include -#include -#include - -namespace some_namespace -{ - class base_class - { - public: - base_class & operator=(const base_class &){ throw int(); } - virtual ~base_class() {} - }; - - class class_without_default_ctor : public base_class - { - public: - char data; - explicit class_without_default_ctor(char arg) : data(arg) {} - }; -} - -int main() -{ - BOOST_TEST_TRAIT_FALSE((boost::has_nothrow_default_constructor)); - return boost::report_errors(); -} diff --git a/test/ak_test_vc14_noexcept.cpp b/test/ak_test_vc14_noexcept.cpp deleted file mode 100644 index 03aa15a..0000000 --- a/test/ak_test_vc14_noexcept.cpp +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright (C) 2014 Andrzej Krzemienski. -// -// Use, modification, and distribution is subject to the Boost Software -// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) -// -// See http://www.boost.org/lib/optional for documentation. -// -// You are welcome to contact the author at: -// akrzemi1@gmail.com - -#include "boost/static_assert.hpp" -#include "boost/optional/optional.hpp" - -#ifdef __BORLANDC__ -#pragma hdrstop -#endif - - -using boost::optional; - -#if defined BOOST_NO_CXX11_NOEXCEPT -BOOST_STATIC_ASSERT_MSG(false, "absent noexcept"); -#endif - -// these 4 classes have different noexcept signatures in move operations -struct NothrowBoth { - NothrowBoth() BOOST_NOEXCEPT {}; - NothrowBoth(NothrowBoth&&) BOOST_NOEXCEPT_IF(true) {}; - void operator=(NothrowBoth&&) BOOST_NOEXCEPT_IF(true) {}; -}; -struct NothrowCtor { - NothrowCtor(NothrowCtor&&) BOOST_NOEXCEPT_IF(true) {}; - void operator=(NothrowCtor&&) BOOST_NOEXCEPT_IF(false) {}; -}; -struct NothrowAssign { - NothrowAssign(NothrowAssign&&) BOOST_NOEXCEPT_IF(false) {}; - void operator=(NothrowAssign&&) BOOST_NOEXCEPT_IF(true) {}; -}; -struct NothrowNone { - NothrowNone(NothrowNone&&) BOOST_NOEXCEPT_IF(false) {}; - void operator=(NothrowNone&&) BOOST_NOEXCEPT_IF(false) {}; -}; - -NothrowBoth ntb; -BOOST_STATIC_ASSERT( BOOST_NOEXCEPT_EXPR( ntb = NothrowBoth() )); - -void test_noexcept_as_defined() // this is a compile-time test -{ - BOOST_STATIC_ASSERT(::boost::is_nothrow_move_constructible::value); - BOOST_STATIC_ASSERT(::boost::is_nothrow_move_assignable::value); - - BOOST_STATIC_ASSERT(::boost::is_nothrow_move_constructible::value); - BOOST_STATIC_ASSERT(!::boost::is_nothrow_move_assignable::value); - - BOOST_STATIC_ASSERT(!::boost::is_nothrow_move_constructible::value); - BOOST_STATIC_ASSERT(::boost::is_nothrow_move_assignable::value); - - BOOST_STATIC_ASSERT(!::boost::is_nothrow_move_constructible::value); - BOOST_STATIC_ASSERT(!::boost::is_nothrow_move_assignable::value); -} - - - -int main() -{ - return 0; -} - -