diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1826a08d..6f816687 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -115,7 +115,85 @@ jobs: toolset: "gcc" compiler: "g++-7" cxxstd: "03,11,14,17" - - name: "TOOLSET=clang COMPILER=clang++ CXXSTD=03,11 Job 7" + - name: "TOOLSET=gcc COMPILER=g++-8 CXXSTD=03,11,14,17 Job 7" + buildtype: "boost" + packages: "g++-8" + packages_to_remove: "" + os: "ubuntu-latest" + container: "ubuntu:20.04" + cxx: "g++-8" + sources: "" + llvm_os: "" + llvm_ver: "" + toolset: "gcc" + compiler: "g++-8" + cxxstd: "03,11,14,17" + - name: "TOOLSET=gcc COMPILER=g++-9 CXXSTD=03,11,14,17 Job 8" + buildtype: "boost" + packages: "g++-9" + packages_to_remove: "" + os: "ubuntu-latest" + container: "ubuntu:20.04" + cxx: "g++-9" + sources: "" + llvm_os: "" + llvm_ver: "" + toolset: "gcc" + compiler: "g++-9" + cxxstd: "03,11,14,17" + - name: "TOOLSET=gcc COMPILER=g++-10 CXXSTD=03,11,14,17 Job 9" + buildtype: "boost" + packages: "g++-10" + packages_to_remove: "" + os: "ubuntu-latest" + container: "ubuntu:20.04" + cxx: "g++-10" + sources: "" + llvm_os: "" + llvm_ver: "" + toolset: "gcc" + compiler: "g++-10" + cxxstd: "03,11,14,17" + - name: "TOOLSET=gcc COMPILER=g++-11 CXXSTD=03,11,14,17,20 Job 10" + buildtype: "boost" + packages: "g++-11" + packages_to_remove: "" + os: "ubuntu-latest" + container: "ubuntu:20.04" + cxx: "g++-11" + sources: "" + llvm_os: "" + llvm_ver: "" + toolset: "gcc" + compiler: "g++-11" + cxxstd: "03,11,14,17,20" + - name: "TOOLSET=gcc COMPILER=g++-12 CXXSTD=03,11,14,17,20 Job 11" + buildtype: "boost" + packages: "g++-12" + packages_to_remove: "" + os: "ubuntu-latest" + container: "ubuntu:22.04" + cxx: "g++-12" + sources: "" + llvm_os: "" + llvm_ver: "" + toolset: "gcc" + compiler: "g++-12" + cxxstd: "03,11,14,17,20" + - name: "TOOLSET=gcc COMPILER=g++-13 CXXSTD=03,11,14,17,20 Job 12" + buildtype: "boost" + packages: "g++-13" + packages_to_remove: "" + os: "ubuntu-latest" + container: "ubuntu:23.04" + cxx: "g++-13" + sources: "" + llvm_os: "" + llvm_ver: "" + toolset: "gcc" + compiler: "g++-13" + cxxstd: "03,11,14,17,20" + - name: "TOOLSET=clang COMPILER=clang++ CXXSTD=03,11 Job 13" buildtype: "boost" packages: "clang" packages_to_remove: "" @@ -128,7 +206,7 @@ jobs: toolset: "clang" compiler: "clang++" cxxstd: "03,11" - - name: "TOOLSET=clang COMPILER=clang++-3.5 CXXSTD=03, Job 8" + - name: "TOOLSET=clang COMPILER=clang++-3.5 CXXSTD=03, Job 14" buildtype: "boost" packages: "clang-3.5 libstdc++-4.9-dev" packages_to_remove: "" @@ -141,7 +219,7 @@ jobs: toolset: "clang" compiler: "clang++-3.5" cxxstd: "03,11,14" - - name: "TOOLSET=clang COMPILER=clang++-3.6 CXXSTD=03, Job 9" + - name: "TOOLSET=clang COMPILER=clang++-3.6 CXXSTD=03, Job 15" buildtype: "boost" packages: "clang-3.6" packages_to_remove: "" @@ -154,7 +232,7 @@ jobs: toolset: "clang" compiler: "clang++-3.6" cxxstd: "03,11,14" - - name: "TOOLSET=clang COMPILER=clang++-3.7 CXXSTD=03, Job 10" + - name: "TOOLSET=clang COMPILER=clang++-3.7 CXXSTD=03, Job 16" buildtype: "boost" packages: "clang-3.7" packages_to_remove: "" @@ -167,7 +245,7 @@ jobs: toolset: "clang" compiler: "clang++-3.7" cxxstd: "03,11,14" - - name: "TOOLSET=clang COMPILER=clang++-3.8 CXXSTD=03, Job 11" + - name: "TOOLSET=clang COMPILER=clang++-3.8 CXXSTD=03, Job 17" buildtype: "boost" packages: "clang-3.8 libstdc++-4.9-dev" packages_to_remove: "" @@ -180,7 +258,7 @@ jobs: toolset: "clang" compiler: "clang++-3.8" cxxstd: "03,11,14" - - name: "TOOLSET=clang COMPILER=clang++-3.9 CXXSTD=03, Job 12" + - name: "TOOLSET=clang COMPILER=clang++-3.9 CXXSTD=03, Job 18" buildtype: "boost" packages: "clang-3.9 libstdc++-4.9-dev" packages_to_remove: "" @@ -193,7 +271,7 @@ jobs: toolset: "clang" compiler: "clang++-3.9" cxxstd: "03,11,14" - - name: "TOOLSET=clang COMPILER=clang++-4.0 CXXSTD=03, Job 13" + - name: "TOOLSET=clang COMPILER=clang++-4.0 CXXSTD=03, Job 19" buildtype: "boost" packages: "clang-4.0" packages_to_remove: "" @@ -206,7 +284,7 @@ jobs: toolset: "clang" compiler: "clang++-4.0" cxxstd: "03,11,14" - - name: "TOOLSET=clang COMPILER=clang++-5.0 CXXSTD=03, Job 14" + - name: "TOOLSET=clang COMPILER=clang++-5.0 CXXSTD=03, Job 20" buildtype: "boost" packages: "clang-5.0" packages_to_remove: "" @@ -266,7 +344,7 @@ jobs: if [ -n "$PACKAGES_TO_REMOVE" ]; then sudo apt-get purge -y $PACKAGES_TO_REMOVE; fi echo ">>>>> APT: REPO.." for i in {1..3}; do sudo -E apt-add-repository -y "ppa:ubuntu-toolchain-r/test" && break || sleep 2; done - + if test -n "${LLVM_OS}" ; then wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add - if test -n "${LLVM_VER}" ; then diff --git a/include/boost/optional/detail/old_optional_implementation.hpp b/include/boost/optional/detail/old_optional_implementation.hpp index 75d4bdcf..36f1a8de 100644 --- a/include/boost/optional/detail/old_optional_implementation.hpp +++ b/include/boost/optional/detail/old_optional_implementation.hpp @@ -67,9 +67,9 @@ void prevent_binding_rvalue_ref_to_optional_lvalue_ref() { #ifndef BOOST_OPTIONAL_CONFIG_ALLOW_BINDING_TO_RVALUES BOOST_STATIC_ASSERT_MSG( - !boost::is_lvalue_reference::value || !boost::is_rvalue_reference::value, + !boost::is_lvalue_reference::value || !boost::is_rvalue_reference::value, "binding rvalue references to optional lvalue references is disallowed"); -#endif +#endif } struct optional_tag {} ; @@ -222,7 +222,7 @@ class optional_base : public optional_tag construct(rhs.get_impl()); } } - + #ifndef BOOST_OPTIONAL_DETAIL_NO_RVALUE_REFERENCES // Assigns from another optional (deep-moves the rhs value) void assign ( optional_base&& rhs ) @@ -239,7 +239,7 @@ class optional_base : public optional_tag construct(boost::move(rhs.get_impl())); } } -#endif +#endif // Assigns from another _convertible_ optional (deep-copies the rhs value) template @@ -253,7 +253,7 @@ class optional_base : public optional_tag #else assign_value(static_cast(rhs.get()), is_reference_predicate() ); #endif - + else destroy(); } else @@ -286,7 +286,7 @@ class optional_base : public optional_tag } } #endif - + // Assigns from a T (deep-copies the rhs value) void assign ( argument_type val ) { @@ -294,7 +294,7 @@ class optional_base : public optional_tag assign_value(val, is_reference_predicate() ); else construct(val); } - + #ifndef BOOST_OPTIONAL_DETAIL_NO_RVALUE_REFERENCES // Assigns from a T (deep-moves the rhs value) void assign ( rval_reference_type val ) @@ -355,7 +355,7 @@ class optional_base : public optional_tag ::new (m_storage.address()) internal_type(val) ; m_initialized = true ; } - + #ifndef BOOST_OPTIONAL_DETAIL_NO_RVALUE_REFERENCES void construct ( rval_reference_type val ) { @@ -383,7 +383,7 @@ class optional_base : public optional_tag ::new (m_storage.address()) internal_type( boost::forward(arg) ); m_initialized = true ; } - + void emplace_assign () { destroy(); @@ -398,7 +398,7 @@ class optional_base : public optional_tag ::new (m_storage.address()) internal_type( arg ); m_initialized = true ; } - + template void emplace_assign ( Arg& arg ) { @@ -406,7 +406,7 @@ class optional_base : public optional_tag ::new (m_storage.address()) internal_type( arg ); m_initialized = true ; } - + void emplace_assign () { destroy(); @@ -615,8 +615,8 @@ class optional_base : public optional_tag #endif // reference_content lacks an implicit conversion to T&, so the following is needed to obtain a proper reference. - reference_const_type dereference( internal_type const* p, is_not_reference_tag ) const { return *p ; } - reference_type dereference( internal_type* p, is_not_reference_tag ) { return *p ; } + reference_const_type dereference( internal_type const* p, is_not_reference_tag ) const { return *boost::core::launder(p) ; } + reference_type dereference( internal_type* p, is_not_reference_tag ) { return *boost::core::launder(p) ; } reference_const_type dereference( internal_type const* p, is_reference_tag ) const { return p->get() ; } reference_type dereference( internal_type* p, is_reference_tag ) { return p->get() ; } @@ -677,7 +677,7 @@ class optional : public optional_detail::optional_base #ifndef BOOST_OPTIONAL_DETAIL_NO_RVALUE_REFERENCES // Creates an optional initialized with 'move(val)'. // Can throw if T::T(T &&) does - optional ( rval_reference_type val ) : base( boost::forward(val) ) + optional ( rval_reference_type val ) : base( boost::forward(val) ) {optional_detail::prevent_binding_rvalue_ref_to_optional_lvalue_ref();} #endif @@ -698,7 +698,7 @@ class optional : public optional_detail::optional_base if ( rhs.is_initialized() ) this->construct(rhs.get()); } - + #ifndef BOOST_OPTIONAL_DETAIL_NO_RVALUE_REFERENCES // Creates a deep move of another convertible optional // Requires a valid conversion from U to T. @@ -727,12 +727,12 @@ class optional : public optional_detail::optional_base template - explicit optional ( Expr&& expr, + explicit optional ( Expr&& expr, BOOST_DEDUCED_TYPENAME boost::disable_if_c< - (boost::is_base_of::type>::value) || - boost::is_same::type, none_t>::value, bool >::type = true - ) - : base(boost::forward(expr),boost::addressof(expr)) + (boost::is_base_of::type>::value) || + boost::is_same::type, none_t>::value, bool >::type = true + ) + : base(boost::forward(expr),boost::addressof(expr)) {optional_detail::prevent_binding_rvalue_ref_to_optional_lvalue_ref();} #else @@ -764,10 +764,10 @@ class optional : public optional_detail::optional_base template BOOST_DEDUCED_TYPENAME boost::disable_if_c< - boost::is_base_of::type>::value || + boost::is_base_of::type>::value || boost::is_same::type, none_t>::value, optional& - >::type + >::type operator= ( Expr&& expr ) { optional_detail::prevent_binding_rvalue_ref_to_optional_lvalue_ref(); @@ -794,7 +794,7 @@ class optional : public optional_detail::optional_base this->assign(rhs); return *this ; } - + #ifndef BOOST_OPTIONAL_DETAIL_NO_RVALUE_REFERENCES // Move-assigns from another convertible optional (converts && deep-moves the rhs value) // Requires a valid conversion from U to T. @@ -818,7 +818,7 @@ class optional : public optional_detail::optional_base #ifndef BOOST_OPTIONAL_DETAIL_NO_RVALUE_REFERENCES // Assigns from another optional (deep-moves the rhs value) - optional& operator= ( optional && rhs ) + optional& operator= ( optional && rhs ) BOOST_NOEXCEPT_IF(::boost::is_nothrow_move_constructible::value && ::boost::is_nothrow_move_assignable::value) { this->assign( static_cast(rhs) ) ; @@ -852,7 +852,7 @@ class optional : public optional_detail::optional_base this->assign( none_ ) ; return *this ; } - + #if (!defined BOOST_OPTIONAL_DETAIL_NO_RVALUE_REFERENCES) && (!defined BOOST_NO_CXX11_VARIADIC_TEMPLATES) // Constructs in-place // upon exception *this is always uninitialized @@ -867,7 +867,7 @@ class optional : public optional_detail::optional_base { this->emplace_assign( boost::forward(arg) ); } - + void emplace () { this->emplace_assign(); @@ -878,13 +878,13 @@ class optional : public optional_detail::optional_base { this->emplace_assign( arg ); } - + template void emplace ( Arg& arg ) { this->emplace_assign( arg ); } - + void emplace () { this->emplace_assign(); @@ -918,7 +918,7 @@ class optional : public optional_detail::optional_base // Returns a reference to the value if this is initialized, otherwise, // the behaviour is UNDEFINED // No-throw -#if (!defined BOOST_NO_CXX11_REF_QUALIFIERS) && (!defined BOOST_OPTIONAL_DETAIL_NO_RVALUE_REFERENCES) +#if (!defined BOOST_NO_CXX11_REF_QUALIFIERS) && (!defined BOOST_OPTIONAL_DETAIL_NO_RVALUE_REFERENCES) reference_const_type operator *() const& { return this->get() ; } reference_type operator *() & { return this->get() ; } reference_type_of_temporary_wrapper operator *() && { return base::types::move(this->get()) ; } @@ -927,42 +927,42 @@ class optional : public optional_detail::optional_base reference_type operator *() { return this->get() ; } #endif // !defined BOOST_NO_CXX11_REF_QUALIFIERS -#if (!defined BOOST_NO_CXX11_REF_QUALIFIERS) && (!defined BOOST_OPTIONAL_DETAIL_NO_RVALUE_REFERENCES) +#if (!defined BOOST_NO_CXX11_REF_QUALIFIERS) && (!defined BOOST_OPTIONAL_DETAIL_NO_RVALUE_REFERENCES) reference_const_type value() const& - { + { if (this->is_initialized()) return this->get() ; else throw_exception(bad_optional_access()); } - + reference_type value() & - { + { if (this->is_initialized()) return this->get() ; else throw_exception(bad_optional_access()); } - + reference_type_of_temporary_wrapper value() && - { + { if (this->is_initialized()) return base::types::move(this->get()) ; else throw_exception(bad_optional_access()); } -#else +#else reference_const_type value() const - { + { if (this->is_initialized()) return this->get() ; else throw_exception(bad_optional_access()); } - + reference_type value() - { + { if (this->is_initialized()) return this->get() ; else @@ -974,16 +974,16 @@ class optional : public optional_detail::optional_base #ifndef BOOST_NO_CXX11_REF_QUALIFIERS template value_type value_or ( U&& v ) const& - { + { if (this->is_initialized()) return get(); else return boost::forward(v); } - + template - value_type value_or ( U&& v ) && - { + value_type value_or ( U&& v ) && + { if (this->is_initialized()) return base::types::move(get()); else @@ -991,7 +991,7 @@ class optional : public optional_detail::optional_base } #elif !defined BOOST_OPTIONAL_DETAIL_NO_RVALUE_REFERENCES template - value_type value_or ( U&& v ) const + value_type value_or ( U&& v ) const { if (this->is_initialized()) return get(); @@ -1000,17 +1000,17 @@ class optional : public optional_detail::optional_base } #else template - value_type value_or ( U const& v ) const - { + value_type value_or ( U const& v ) const + { if (this->is_initialized()) return get(); else return v; } - + template - value_type value_or ( U& v ) const - { + value_type value_or ( U& v ) const + { if (this->is_initialized()) return get(); else @@ -1028,7 +1028,7 @@ class optional : public optional_detail::optional_base else return f(); } - + template value_type value_or_eval ( F f ) && { @@ -1047,9 +1047,9 @@ class optional : public optional_detail::optional_base return f(); } #endif - + bool operator!() const BOOST_NOEXCEPT { return !this->is_initialized() ; } - + BOOST_EXPLICIT_OPERATOR_BOOL_NOEXCEPT() } ; diff --git a/include/boost/optional/detail/optional_aligned_storage.hpp b/include/boost/optional/detail/optional_aligned_storage.hpp index b290921d..b859e874 100644 --- a/include/boost/optional/detail/optional_aligned_storage.hpp +++ b/include/boost/optional/detail/optional_aligned_storage.hpp @@ -28,6 +28,8 @@ class aligned_storage // BOOST_MAY_ALIAS works around GCC warnings about breaking strict aliasing rules when casting storage address to T* union BOOST_MAY_ALIAS dummy_u { + dummy_u(){} + ~dummy_u(){} unsigned char data[ sizeof(T) ]; BOOST_DEDUCED_TYPENAME type_with_alignment< ::boost::alignment_of::value >::type aligner_; @@ -60,9 +62,9 @@ class aligned_storage T * ptr_ref() { return static_cast (address()); } #endif - T const& ref() const { return *ptr_ref(); } - T & ref() { return *ptr_ref(); } - + T const& ref() const { return *boost::core::launder(ptr_ref()); } + T & ref() { return *boost::core::launder(ptr_ref()); } + } ; } // namespace optional_detail diff --git a/include/boost/optional/detail/optional_trivially_copyable_base.hpp b/include/boost/optional/detail/optional_trivially_copyable_base.hpp index 8d98a844..9ee76fd3 100644 --- a/include/boost/optional/detail/optional_trivially_copyable_base.hpp +++ b/include/boost/optional/detail/optional_trivially_copyable_base.hpp @@ -39,7 +39,7 @@ class tc_optional_base : public optional_tag tc_optional_base ( none_t ) : - m_initialized(false) {} + m_initialized(false), m_storage() {} tc_optional_base ( init_value_tag, argument_type val ) : @@ -497,8 +497,8 @@ class tc_optional_base : public optional_tag m_initialized = false; } - reference_const_type get_impl() const { return m_storage ; } - reference_type get_impl() { return m_storage ; } + reference_const_type get_impl() const { return *boost::core::launder(&m_storage) ; } + reference_type get_impl() { return *boost::core::launder(&m_storage) ; } pointer_const_type get_ptr_impl() const { return boost::addressof(m_storage); } pointer_type get_ptr_impl() { return boost::addressof(m_storage); } diff --git a/include/boost/optional/optional.hpp b/include/boost/optional/optional.hpp index f5fdf992..2a183c54 100644 --- a/include/boost/optional/optional.hpp +++ b/include/boost/optional/optional.hpp @@ -31,6 +31,7 @@ #include #include #include +#include #include #include #include