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..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 @@ -11,6 +11,11 @@ [section:relnotes Release Notes] +[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] * Added member function `has_value()` for compatibility with `std::optional` ([@https://github.com/boostorg/optional/issues/52 issue #52]). 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. +

space

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 + );

space 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 ; R - // deprecated methods - - // (deprecated) void reset() noexcept ; R + // deprecated methods + // (deprecated) template<class R> void reset ( R && r ) noexcept ; R 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 ; R - // deprecated methods - - // (deprecated) void reset() noexcept ; R + // deprecated methods + // (deprecated) void reset ( T const& ) ; R diff --git a/doc/html/boost_optional/relnotes.html b/doc/html/boost_optional/relnotes.html index f074211..dcf21f9 100644 --- a/doc/html/boost_optional/relnotes.html +++ b/doc/html/boost_optional/relnotes.html @@ -28,6 +28,20 @@

+ Boost + Release 1.69 +

+
    +
  • + Remove deprecation mark from reset() method (without arguments). +
  • +
  • + Fixed issue + #59. +
  • +
+

+ Boost Release 1.68

@@ -44,7 +58,7 @@

- + Boost Release 1.67

@@ -58,7 +72,7 @@

- + Boost Release 1.66

@@ -76,7 +90,7 @@

- + Boost Release 1.63

@@ -100,7 +114,7 @@

- + Boost Release 1.62

@@ -108,7 +122,7 @@ Fixed Trac #12179.

- + Boost Release 1.61

@@ -151,7 +165,7 @@

- + Boost Release 1.60

@@ -162,7 +176,7 @@ #11203.

- + Boost Release 1.59

@@ -176,7 +190,7 @@

- + Boost Release 1.58

@@ -212,7 +226,7 @@

- + Boost Release 1.57

@@ -222,7 +236,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 c563c86..4fe8adc 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 29, 2018 at 21:06:01 GMT


diff --git a/include/boost/optional/detail/old_optional_implementation.hpp b/include/boost/optional/detail/old_optional_implementation.hpp index 62c31ee..f8dc260 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 ; @@ -333,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(); } @@ -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 ; } diff --git a/include/boost/optional/detail/optional_trivially_copyable_base.hpp b/include/boost/optional/detail/optional_trivially_copyable_base.hpp index 91328ac..0734f62 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) @@ -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(); } diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 9000c2a..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 ] @@ -49,6 +50,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_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 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(); +}