From c52280bb78426e65dd1018d2f0542aecd1f14293 Mon Sep 17 00:00:00 2001
From: Peter Dimov
Date: Wed, 12 Sep 2018 20:02:47 +0300
Subject: [PATCH 1/7] Remove dependency on MPL
---
.../detail/old_optional_implementation.hpp | 19 +++++++++----------
1 file changed, 9 insertions(+), 10 deletions(-)
diff --git a/include/boost/optional/detail/old_optional_implementation.hpp b/include/boost/optional/detail/old_optional_implementation.hpp
index 62c31ee..b35ba8b 100644
--- a/include/boost/optional/detail/old_optional_implementation.hpp
+++ b/include/boost/optional/detail/old_optional_implementation.hpp
@@ -14,10 +14,9 @@
#define BOOST_OPTIONAL_DETAIL_OLD_OPTIONAL_IMPLEMENTATION_AJK_28JAN2015_HPP
#include
-#include
-#include
-#include
#include
+#include
+#include
namespace boost {
@@ -96,13 +95,13 @@ class optional_base : public optional_tag
typedef T value_type ;
- typedef mpl::true_ is_reference_tag ;
- typedef mpl::false_ is_not_reference_tag ;
+ typedef true_type is_reference_tag ;
+ typedef false_type is_not_reference_tag ;
typedef BOOST_DEDUCED_TYPENAME is_reference::type is_reference_predicate ;
public:
- typedef BOOST_DEDUCED_TYPENAME mpl::if_::type types ;
+ typedef BOOST_DEDUCED_TYPENAME conditional::type types ;
protected:
typedef BOOST_DEDUCED_TYPENAME types::reference_type reference_type ;
@@ -422,7 +421,7 @@ class optional_base : public optional_tag
template
void construct ( Expr&& factory, in_place_factory_base const* )
{
- BOOST_STATIC_ASSERT ( ::boost::mpl::not_::value ) ;
+ BOOST_STATIC_ASSERT ( !is_reference_predicate::value ) ;
boost_optional_detail::construct(factory, m_storage.address());
m_initialized = true ;
}
@@ -431,7 +430,7 @@ class optional_base : public optional_tag
template
void construct ( Expr&& factory, typed_in_place_factory_base const* )
{
- BOOST_STATIC_ASSERT ( ::boost::mpl::not_::value ) ;
+ BOOST_STATIC_ASSERT ( !is_reference_predicate::value ) ;
factory.apply(m_storage.address()) ;
m_initialized = true ;
}
@@ -456,7 +455,7 @@ class optional_base : public optional_tag
template
void construct ( Expr const& factory, in_place_factory_base const* )
{
- BOOST_STATIC_ASSERT ( ::boost::mpl::not_::value ) ;
+ BOOST_STATIC_ASSERT ( !is_reference_predicate::value ) ;
boost_optional_detail::construct(factory, m_storage.address());
m_initialized = true ;
}
@@ -465,7 +464,7 @@ class optional_base : public optional_tag
template
void construct ( Expr const& factory, typed_in_place_factory_base const* )
{
- BOOST_STATIC_ASSERT ( ::boost::mpl::not_::value ) ;
+ BOOST_STATIC_ASSERT ( !is_reference_predicate::value ) ;
factory.apply(m_storage.address()) ;
m_initialized = true ;
}
From 350ebab88a5e86a68bcfd519d0b4866c0dfcfa8c Mon Sep 17 00:00:00 2001
From: Nikita Kniazev
Date: Fri, 5 Oct 2018 18:45:58 +0300
Subject: [PATCH 2/7] Workaround GCC 8-9 regression
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87531
---
.../boost/optional/detail/optional_trivially_copyable_base.hpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/boost/optional/detail/optional_trivially_copyable_base.hpp b/include/boost/optional/detail/optional_trivially_copyable_base.hpp
index 91328ac..d2e55fa 100644
--- a/include/boost/optional/detail/optional_trivially_copyable_base.hpp
+++ b/include/boost/optional/detail/optional_trivially_copyable_base.hpp
@@ -71,7 +71,7 @@ class tc_optional_base : public optional_tag
// Assigns from another optional (deep-copies the rhs value)
void assign ( tc_optional_base const& rhs )
{
- this->operator=(rhs);
+ *this = rhs;
}
// Assigns from another _convertible_ optional (deep-copies the rhs value)
From bebc606a4cf9c1436dbe929f1686e677d5815e5e Mon Sep 17 00:00:00 2001
From: Nikita Kniazev
Date: Tue, 23 Oct 2018 02:20:23 +0300
Subject: [PATCH 3/7] Remove deprecation mark from `reset()`
The `std::optional` has `reset()` [optional.mod] and it is not deprecated.
---
doc/27_ref_optional_synopsis.qbk | 10 ++++------
doc/28_ref_optional_semantics.qbk | 5 ++---
doc/91_relnotes.qbk | 4 ++++
.../optional/detail/old_optional_implementation.hpp | 2 +-
.../detail/optional_trivially_copyable_base.hpp | 2 +-
include/boost/optional/optional.hpp | 2 +-
6 files changed, 13 insertions(+), 12 deletions(-)
diff --git a/doc/27_ref_optional_synopsis.qbk b/doc/27_ref_optional_synopsis.qbk
index 7114b43..bcd18e8 100644
--- a/doc/27_ref_optional_synopsis.qbk
+++ b/doc/27_ref_optional_synopsis.qbk
@@ -196,11 +196,10 @@ They are empty, trivially copyable classes with disabled default constructor.
bool operator!() const noexcept ; ``[link reference_optional_operator_not __GO_TO__]``
- // deprecated methods
-
- // (deprecated)
void reset() noexcept ; ``[link reference_optional_reset __GO_TO__]``
+ // deprecated methods
+
// (deprecated)
void reset ( T const& ) ; ``[link reference_optional_reset_value __GO_TO__]``
@@ -275,11 +274,10 @@ They are empty, trivially copyable classes with disabled default constructor.
bool operator!() const noexcept ; ``[link reference_optional_ref_operator_not __GO_TO__]``
- // deprecated methods
-
- // (deprecated)
void reset() noexcept ; ``[link reference_optional_ref_reset __GO_TO__]``
+ // deprecated methods
+
// (deprecated)
template void reset ( R && r ) noexcept ; ``[link reference_optional_ref_reset_value __GO_TO__]``
diff --git a/doc/28_ref_optional_semantics.qbk b/doc/28_ref_optional_semantics.qbk
index 6ce0d2e..2fa7500 100644
--- a/doc/28_ref_optional_semantics.qbk
+++ b/doc/28_ref_optional_semantics.qbk
@@ -541,7 +541,7 @@ __SPACE__
[#reference_optional_reset]
[: `void optional::reset() noexcept ;`]
-* [*Deprecated:] Same as `operator=( none_t );`
+* [*Effects:] Same as `operator=( none_t );`
__SPACE__
@@ -1129,8 +1129,7 @@ __SPACE__
[#reference_optional_ref_reset]
[: `void optional::reset() noexcept;`]
-* [*Effects:] Use `*this = none` instead.
-* [*Remarks:] This function is depprecated.
+* [*Effects:] Same as `*this = none`.
__SPACE__
diff --git a/doc/91_relnotes.qbk b/doc/91_relnotes.qbk
index b7d410f..92648d0 100644
--- a/doc/91_relnotes.qbk
+++ b/doc/91_relnotes.qbk
@@ -11,6 +11,10 @@
[section:relnotes Release Notes]
+[heading Boost Release 1.69]
+
+* Remove deprecation mark from `reset()` method (without arguments).
+
[heading Boost Release 1.68]
* Added member function `has_value()` for compatibility with `std::optional` ([@https://github.com/boostorg/optional/issues/52 issue #52]).
diff --git a/include/boost/optional/detail/old_optional_implementation.hpp b/include/boost/optional/detail/old_optional_implementation.hpp
index b35ba8b..f8dc260 100644
--- a/include/boost/optional/detail/old_optional_implementation.hpp
+++ b/include/boost/optional/detail/old_optional_implementation.hpp
@@ -332,7 +332,7 @@ class optional_base : public optional_tag
public :
- // **DEPPRECATED** Destroys the current value, if any, leaving this UNINITIALIZED
+ // Destroys the current value, if any, leaving this UNINITIALIZED
// No-throw (assuming T::~T() doesn't)
void reset() BOOST_NOEXCEPT { destroy(); }
diff --git a/include/boost/optional/detail/optional_trivially_copyable_base.hpp b/include/boost/optional/detail/optional_trivially_copyable_base.hpp
index d2e55fa..0734f62 100644
--- a/include/boost/optional/detail/optional_trivially_copyable_base.hpp
+++ b/include/boost/optional/detail/optional_trivially_copyable_base.hpp
@@ -127,7 +127,7 @@ class tc_optional_base : public optional_tag
public :
- // **DEPPRECATED** Destroys the current value, if any, leaving this UNINITIALIZED
+ // Destroys the current value, if any, leaving this UNINITIALIZED
// No-throw (assuming T::~T() doesn't)
void reset() BOOST_NOEXCEPT { destroy(); }
diff --git a/include/boost/optional/optional.hpp b/include/boost/optional/optional.hpp
index 01cb2bd..104bca4 100644
--- a/include/boost/optional/optional.hpp
+++ b/include/boost/optional/optional.hpp
@@ -378,7 +378,7 @@ class optional_base : public optional_tag
public :
- // **DEPPRECATED** Destroys the current value, if any, leaving this UNINITIALIZED
+ // Destroys the current value, if any, leaving this UNINITIALIZED
// No-throw (assuming T::~T() doesn't)
void reset() BOOST_NOEXCEPT { destroy(); }
From 0f8e356bca18a23249b9dfcadd0e62928a528626 Mon Sep 17 00:00:00 2001
From: Andrzej Krzemienski
Date: Tue, 23 Oct 2018 22:46:26 +0200
Subject: [PATCH 4/7] rebuilt docs
---
...ailed_semantics___optional_references.html | 11 ++------
.../detailed_semantics___optional_values.html | 4 +--
.../header_optional_optional_refs.html | 5 ++--
.../header_optional_optional_values.html | 5 ++--
doc/html/boost_optional/relnotes.html | 28 ++++++++++++-------
doc/html/index.html | 2 +-
6 files changed, 28 insertions(+), 27 deletions(-)
diff --git a/doc/html/boost_optional/reference/header__boost_optional_optional_hpp_/detailed_semantics___optional_references.html b/doc/html/boost_optional/reference/header__boost_optional_optional_hpp_/detailed_semantics___optional_references.html
index 99b8cb8..e526f76 100644
--- a/doc/html/boost_optional/reference/header__boost_optional_optional_hpp_/detailed_semantics___optional_references.html
+++ b/doc/html/boost_optional/reference/header__boost_optional_optional_hpp_/detailed_semantics___optional_references.html
@@ -486,14 +486,9 @@
void optional<T&>::reset() noexcept;
-
--
- Effects: Use
*this = none
instead.
-
--
- Remarks: This function is depprecated.
-
-
+-
+ Effects: Same as
*this = none
.
+
diff --git a/doc/html/boost_optional/reference/header__boost_optional_optional_hpp_/detailed_semantics___optional_values.html b/doc/html/boost_optional/reference/header__boost_optional_optional_hpp_/detailed_semantics___optional_values.html
index 42af248..ca180f4 100644
--- a/doc/html/boost_optional/reference/header__boost_optional_optional_hpp_/detailed_semantics___optional_values.html
+++ b/doc/html/boost_optional/reference/header__boost_optional_optional_hpp_/detailed_semantics___optional_values.html
@@ -1199,8 +1199,8 @@
;
-
- Deprecated: Same as
operator=(
- none_t );
+ Effects: Same as operator=( none_t
+ );
diff --git a/doc/html/boost_optional/reference/header__boost_optional_optional_hpp_/header_optional_optional_refs.html b/doc/html/boost_optional/reference/header__boost_optional_optional_hpp_/header_optional_optional_refs.html
index 43b0c0a..8cef0ab 100644
--- a/doc/html/boost_optional/reference/header__boost_optional_optional_hpp_/header_optional_optional_refs.html
+++ b/doc/html/boost_optional/reference/header__boost_optional_optional_hpp_/header_optional_optional_refs.html
@@ -84,11 +84,10 @@
bool operator!() const noexcept ;
-
-
-
void reset() noexcept ;
+
+
template<class R> void reset ( R && r ) noexcept ;
diff --git a/doc/html/boost_optional/reference/header__boost_optional_optional_hpp_/header_optional_optional_values.html b/doc/html/boost_optional/reference/header__boost_optional_optional_hpp_/header_optional_optional_values.html
index 5e1edff..f6ed7da 100644
--- a/doc/html/boost_optional/reference/header__boost_optional_optional_hpp_/header_optional_optional_values.html
+++ b/doc/html/boost_optional/reference/header__boost_optional_optional_hpp_/header_optional_optional_values.html
@@ -122,11 +122,10 @@
bool operator!() const noexcept ;
-
-
-
void reset() noexcept ;
+
+
void reset ( T const& ) ;
diff --git a/doc/html/boost_optional/relnotes.html b/doc/html/boost_optional/relnotes.html
index f074211..c20a446 100644
--- a/doc/html/boost_optional/relnotes.html
+++ b/doc/html/boost_optional/relnotes.html
@@ -28,6 +28,14 @@
+-
+ Remove deprecation mark from
reset()
method (without arguments).
+
+
@@ -44,7 +52,7 @@
@@ -58,7 +66,7 @@
@@ -76,7 +84,7 @@
@@ -100,7 +108,7 @@
@@ -108,7 +116,7 @@
Fixed Trac #12179.
@@ -151,7 +159,7 @@
@@ -162,7 +170,7 @@
#11203.
@@ -176,7 +184,7 @@
@@ -212,7 +220,7 @@
@@ -222,7 +230,7 @@
to fix C++03 compile error on logic_error("...")
".
diff --git a/doc/html/index.html b/doc/html/index.html
index c563c86..80f7644 100644
--- a/doc/html/index.html
+++ b/doc/html/index.html
@@ -145,7 +145,7 @@
-Last revised: July 02, 2018 at 21:10:01 GMT |
+Last revised: October 23, 2018 at 20:41:10 GMT |
|
From fae2791f45758e4eaf0972c3aea8a285137d30f5 Mon Sep 17 00:00:00 2001
From: Andrzej Krzemienski
Date: Thu, 25 Oct 2018 00:37:13 +0200
Subject: [PATCH 5/7] added test for swapping const opitonals
---
test/Jamfile.v2 | 1 +
test/optional_test_fail_const_swap.cpp | 26 ++++++++++++++++++++++++++
2 files changed, 27 insertions(+)
create mode 100644 test/optional_test_fail_const_swap.cpp
diff --git a/test/Jamfile.v2 b/test/Jamfile.v2
index 9000c2a..8126239 100644
--- a/test/Jamfile.v2
+++ b/test/Jamfile.v2
@@ -49,6 +49,7 @@ import testing ;
[ run optional_test_member_T.cpp ]
[ run optional_test_tc_base.cpp ]
[ compile optional_test_sfinae_friendly_ctor.cpp ]
+ [ compile-fail optional_test_fail_const_swap.cpp ]
[ compile-fail optional_test_ref_convert_assign_const_int_prevented.cpp ]
[ compile-fail optional_test_fail1.cpp ]
[ compile-fail optional_test_fail3a.cpp ]
diff --git a/test/optional_test_fail_const_swap.cpp b/test/optional_test_fail_const_swap.cpp
new file mode 100644
index 0000000..3d97a1c
--- /dev/null
+++ b/test/optional_test_fail_const_swap.cpp
@@ -0,0 +1,26 @@
+// Copyright (C) 2018, 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/optional.hpp"
+
+// THIS TEST SHOULD FAIL TO COMPILE
+
+void test_converitng_assignment_of_different_enums()
+{
+ const boost::optional o1(1);
+ const boost::optional o2(2);
+ swap(o1, o2); // no swap on const objects should compile
+}
+
+int main()
+{
+ test_converitng_assignment_of_different_enums();
+}
From 65bb040db89cc33d0ed5676545623dd62e506f98 Mon Sep 17 00:00:00 2001
From: Andrzej Krzemienski
Date: Mon, 29 Oct 2018 21:47:09 +0100
Subject: [PATCH 6/7] tests: added two test cases from GitHub issues
---
test/Jamfile.v2 | 1 +
test/optional_test_assign.cpp | 30 +++++++++++++++++++
test/optional_test_deleted_default_ctor.cpp | 32 +++++++++++++++++----
3 files changed, 58 insertions(+), 5 deletions(-)
create mode 100644 test/optional_test_assign.cpp
diff --git a/test/Jamfile.v2 b/test/Jamfile.v2
index 8126239..f6912a9 100644
--- a/test/Jamfile.v2
+++ b/test/Jamfile.v2
@@ -18,6 +18,7 @@ import testing ;
{
test-suite optional :
[ run optional_test.cpp ]
+ [ run optional_test_assign.cpp ]
[ run optional_test_swap.cpp ]
[ run optional_test_conversions_from_U.cpp ]
[ run optional_test_convert_from_T.cpp ]
diff --git a/test/optional_test_assign.cpp b/test/optional_test_assign.cpp
new file mode 100644
index 0000000..07dfcdc
--- /dev/null
+++ b/test/optional_test_assign.cpp
@@ -0,0 +1,30 @@
+// Copyright (C) 2018 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/core/lightweight_test.hpp"
+#include "boost/optional/optional.hpp"
+
+void test_assignment_to_empty()
+{
+ // this test used to fail on GCC 8.1.0/8.2.0/9.0.0 with -std=c++98
+ boost::optional oa, ob(1);
+ BOOST_TEST(!oa);
+ BOOST_TEST(ob);
+
+ oa = ob;
+ BOOST_TEST(oa);
+}
+
+int main()
+{
+ test_assignment_to_empty();
+ return boost::report_errors();
+}
diff --git a/test/optional_test_deleted_default_ctor.cpp b/test/optional_test_deleted_default_ctor.cpp
index e98b381..790753c 100644
--- a/test/optional_test_deleted_default_ctor.cpp
+++ b/test/optional_test_deleted_default_ctor.cpp
@@ -1,4 +1,6 @@
// Copyright 2017 Peter Dimov
+// Copyright 2017 Vinnie NotDefaultConstructible
+// Copyright 2018 Andrzej Krzemienski
//
// Distributed under the Boost Software License, Version 1.0.
//
@@ -19,8 +21,8 @@ int main()
class basic_multi_buffer;
-class const_buffers_type
-{
+class const_buffers_type // a similar declaration in boost.beast had problem
+{ // with boost opitonal
basic_multi_buffer const* b_;
friend class basic_multi_buffer;
@@ -29,16 +31,36 @@ class const_buffers_type
const_buffers_type(basic_multi_buffer const& b);
public:
-
const_buffers_type() = delete;
const_buffers_type(const_buffers_type const&) = default;
const_buffers_type& operator=(const_buffers_type const&) = default;
};
+void test_beast_example()
+{
+ // test if it even compiles
+ boost::optional< std::pair > opt, opt2;
+ opt = opt2;
+ (void)opt;
+}
+
+struct NotDefaultConstructible // minimal class exposing the problem
+{
+ NotDefaultConstructible() = delete;
+};
+
+void test_assign_for_non_default_constructible()
+{
+ // test if it even compiles
+ boost::optional opt, opt2;
+ opt = opt2;
+ (void)opt;
+}
+
int main()
{
- boost::optional< std::pair > opt, opt2;
- opt = opt2;
+ test_beast_example();
+ test_assign_for_non_default_constructible();
}
#endif
From 69e239530e1dd2a84e71afeec7d0d547f6f6d482 Mon Sep 17 00:00:00 2001
From: Andrzej Krzemienski
Date: Mon, 29 Oct 2018 22:06:47 +0100
Subject: [PATCH 7/7] docs: updated releasenotes
---
doc/91_relnotes.qbk | 3 ++-
doc/html/boost_optional/relnotes.html | 10 ++++++++--
doc/html/index.html | 2 +-
3 files changed, 11 insertions(+), 4 deletions(-)
diff --git a/doc/91_relnotes.qbk b/doc/91_relnotes.qbk
index 92648d0..fcc37f8 100644
--- a/doc/91_relnotes.qbk
+++ b/doc/91_relnotes.qbk
@@ -1,7 +1,7 @@
[/
Boost.Optional
- Copyright (c) 2015, 2016 Andrzej Krzemienski
+ Copyright (c) 2015 - 2018 Andrzej Krzemienski
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE_1_0.txt or copy at
@@ -14,6 +14,7 @@
[heading Boost Release 1.69]
* Remove deprecation mark from `reset()` method (without arguments).
+* Fixed [@https://github.com/boostorg/optional/issues/59 issue #59].
[heading Boost Release 1.68]
diff --git a/doc/html/boost_optional/relnotes.html b/doc/html/boost_optional/relnotes.html
index c20a446..dcf21f9 100644
--- a/doc/html/boost_optional/relnotes.html
+++ b/doc/html/boost_optional/relnotes.html
@@ -31,9 +31,15 @@
Boost
Release 1.69
--
+
+-
Remove deprecation mark from
reset()
method (without arguments).
-
+
+-
+ Fixed issue
+ #59.
+
+
-Last revised: October 23, 2018 at 20:41:10 GMT |
+Last revised: October 29, 2018 at 21:06:01 GMT |
|