diff --git a/CMakeLists.txt b/CMakeLists.txt index a91e7a0..80799e1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,7 +11,7 @@ add_library(boost_optional INTERFACE) add_library(Boost::optional ALIAS boost_optional) target_include_directories(boost_optional INTERFACE include) -if(NOT CMAKE_VERSION VERSION_LESS "3.19") +if(NOT CMAKE_VERSION VERSION_LESS "3.19") file(GLOB_RECURSE headers include/*.hpp) target_sources(boost_optional PRIVATE ${headers}) endif() @@ -21,7 +21,6 @@ target_link_libraries(boost_optional Boost::assert Boost::config Boost::core - Boost::static_assert Boost::throw_exception Boost::type_traits ) diff --git a/build.jam b/build.jam index 6f1fcf6..b08ea0b 100644 --- a/build.jam +++ b/build.jam @@ -9,7 +9,6 @@ constant boost_dependencies : /boost/assert//boost_assert /boost/config//boost_config /boost/core//boost_core - /boost/static_assert//boost_static_assert /boost/throw_exception//boost_throw_exception /boost/type_traits//boost_type_traits ; @@ -22,4 +21,3 @@ explicit call-if : boost-library optional ; - diff --git a/doc/92_relnotes.qbk b/doc/92_relnotes.qbk index 649cad7..e575075 100644 --- a/doc/92_relnotes.qbk +++ b/doc/92_relnotes.qbk @@ -13,9 +13,10 @@ [heading Boost Release 1.87] -* *Breaking change.* Dropped support for C++03. C++11 is now the required minimum. +* *Breaking change.* Dropped support for C++03. C++11 is now the required minimum; at least some C++11 features. * Dropped dependency on Boost.Utility. * Dropped dependency on Boost.Predef. +* Dropped dependency on Boost.StaticAssert. * Dropped dependency on Boost.Move. * A bit faster implementation of some relational operations. * Tags `in_place_init` and `in_place_init_if` become `inline constexpr` and therewith leave smaller footprint in the executable. This addresses [@https://github.com/boostorg/optional/issues/103 issue #103]. diff --git a/include/boost/optional/detail/optional_reference_spec.hpp b/include/boost/optional/detail/optional_reference_spec.hpp index 30824c2..d8405f8 100644 --- a/include/boost/optional/detail/optional_reference_spec.hpp +++ b/include/boost/optional/detail/optional_reference_spec.hpp @@ -29,16 +29,16 @@ template void prevent_binding_rvalue() { #ifndef BOOST_OPTIONAL_CONFIG_ALLOW_BINDING_TO_RVALUES - BOOST_STATIC_ASSERT_MSG(boost::is_lvalue_reference::value, - "binding rvalue references to optional lvalue references is disallowed"); + static_assert(boost::is_lvalue_reference::value, + "binding rvalue references to optional lvalue references is disallowed"); #endif } template BOOST_DEDUCED_TYPENAME boost::remove_reference::type& forward_reference(T&& r) { - BOOST_STATIC_ASSERT_MSG(boost::is_lvalue_reference::value, - "binding rvalue references to optional lvalue references is disallowed"); + static_assert(boost::is_lvalue_reference::value, + "binding rvalue references to optional lvalue references is disallowed"); return optional_detail::forward(r); } @@ -68,8 +68,8 @@ void prevent_assignment_from_false_const_integral() #ifdef BOOST_OPTIONAL_CONFIG_NO_PROPER_ASSIGN_FROM_CONST_INT // MSVC compiler without rvalue references: we need to disable the assignment from // const integral lvalue reference, as it may be an invalid temporary - BOOST_STATIC_ASSERT_MSG(!is_const_integral::value, - "binding const lvalue references to integral types is disabled in this compiler"); + static_assert(!is_const_integral::value, + "binding const lvalue references to integral types is disabled in this compiler"); #endif #endif } diff --git a/include/boost/optional/optional.hpp b/include/boost/optional/optional.hpp index afe42da..0fd4448 100644 --- a/include/boost/optional/optional.hpp +++ b/include/boost/optional/optional.hpp @@ -1053,7 +1053,7 @@ class optional template class optional { - BOOST_STATIC_ASSERT_MSG(sizeof(T) == 0, "Optional rvalue references are illegal."); + static_assert(sizeof(T) == 0, "Optional rvalue references are illegal."); } ; } // namespace boost @@ -1163,7 +1163,7 @@ template std::basic_ostream& 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 "); + static_assert(sizeof(CharType) == 0, "If you want to output boost::optional, include header "); return os; } diff --git a/test/optional_test_convert_assign.cpp b/test/optional_test_convert_assign.cpp index 5e1ceda..a067520 100644 --- a/test/optional_test_convert_assign.cpp +++ b/test/optional_test_convert_assign.cpp @@ -40,9 +40,9 @@ void test_no_bad_assignment() { #if !defined(BOOST_NO_CXX11_DECLTYPE) && !BOOST_WORKAROUND(BOOST_MSVC, < 1800) // this means that type trait `boost::is_assignable` works. - BOOST_STATIC_ASSERT((boost::is_assignable&, bool>::value)); - BOOST_STATIC_ASSERT((boost::is_assignable&, implicit_bool_conv>::value)); - BOOST_STATIC_ASSERT((! boost::is_assignable&, explicit_bool_conv>::value)); + static_assert((boost::is_assignable&, bool>::value), "ERROR"); + static_assert((boost::is_assignable&, implicit_bool_conv>::value), "ERROR"); + static_assert((! boost::is_assignable&, explicit_bool_conv>::value), "ERROR"); #endif } diff --git a/test/optional_test_convert_from_T.cpp b/test/optional_test_convert_from_T.cpp index bfa1a0a..60f94cc 100644 --- a/test/optional_test_convert_from_T.cpp +++ b/test/optional_test_convert_from_T.cpp @@ -28,14 +28,14 @@ struct superconv { #ifndef BOOST_OPTIONAL_DETAIL_NO_RVALUE_REFERENCES template - superconv(T&&) { BOOST_STATIC_ASSERT(sizeof(T) == 0); } + superconv(T&&) { static_assert(sizeof(T) == 0, "ERROR"); } #else template - superconv(const T&) { BOOST_STATIC_ASSERT(sizeof(T) == 0); } + superconv(const T&) { static_assert(sizeof(T) == 0, "ERROR"); } template - superconv( T&) { BOOST_STATIC_ASSERT(sizeof(T) == 0); } + superconv( T&) { static_assert(sizeof(T) == 0, "ERROR"); } #endif - + superconv() {} }; @@ -52,19 +52,19 @@ void test_optional_optional_T() { optional oi1 (1), oiN; optional< optional > ooi1 (oi1), ooiN(oiN); - + BOOST_TEST(ooi1); BOOST_TEST(*ooi1); BOOST_TEST_EQ(**ooi1, 1); - + BOOST_TEST(ooiN); BOOST_TEST(!*ooiN); -} +} int main() { test_optional_optional_T(); test_optional_of_superconverting_T(); - + return boost::report_errors(); } diff --git a/test/optional_test_noexcept_move.cpp b/test/optional_test_noexcept_move.cpp index bc4fa97..6ff8a9a 100644 --- a/test/optional_test_noexcept_move.cpp +++ b/test/optional_test_noexcept_move.cpp @@ -44,36 +44,36 @@ struct NothrowNone { #if 0 // these also test type_traits, which are wrong 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); + static_assert(::boost::is_nothrow_move_constructible::value, "ERROR"); + static_assert(::boost::is_nothrow_move_assignable::value, "ERROR"); + + static_assert(::boost::is_nothrow_move_constructible::value, "ERROR"); + static_assert(!::boost::is_nothrow_move_assignable::value, "ERROR"); + + static_assert(!::boost::is_nothrow_move_constructible::value, "ERROR"); + static_assert(::boost::is_nothrow_move_assignable::value, "ERROR"); + + static_assert(!::boost::is_nothrow_move_constructible::value, "ERROR"); + static_assert(!::boost::is_nothrow_move_assignable::value, "ERROR"); } void test_noexcept_on_optional_with_type_traits() // 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_NOEXCEPT_EXPR(optional())); - - BOOST_STATIC_ASSERT(::boost::is_nothrow_move_constructible >::value); - BOOST_STATIC_ASSERT(!::boost::is_nothrow_move_assignable >::value); - BOOST_STATIC_ASSERT(BOOST_NOEXCEPT_EXPR(optional())); - - BOOST_STATIC_ASSERT(!::boost::is_nothrow_move_constructible >::value); - BOOST_STATIC_ASSERT(!::boost::is_nothrow_move_assignable >::value); - BOOST_STATIC_ASSERT(BOOST_NOEXCEPT_EXPR(optional())); - - BOOST_STATIC_ASSERT(!::boost::is_nothrow_move_constructible >::value); - BOOST_STATIC_ASSERT(!::boost::is_nothrow_move_assignable >::value); - BOOST_STATIC_ASSERT(BOOST_NOEXCEPT_EXPR(optional())); + static_assert(::boost::is_nothrow_move_constructible >::value, "ERROR"); + static_assert(::boost::is_nothrow_move_assignable >::value, "ERROR"); + static_assert(BOOST_NOEXCEPT_EXPR(optional()), "ERROR"); + + static_assert(::boost::is_nothrow_move_constructible >::value, "ERROR"); + static_assert(!::boost::is_nothrow_move_assignable >::value, "ERROR"); + static_assert(BOOST_NOEXCEPT_EXPR(optional()), "ERROR"); + + static_assert(!::boost::is_nothrow_move_constructible >::value, "ERROR"); + static_assert(!::boost::is_nothrow_move_assignable >::value, "ERROR"); + static_assert(BOOST_NOEXCEPT_EXPR(optional()), "ERROR"); + + static_assert(!::boost::is_nothrow_move_constructible >::value, "ERROR"); + static_assert(!::boost::is_nothrow_move_assignable >::value, "ERROR"); + static_assert(BOOST_NOEXCEPT_EXPR(optional()), "ERROR"); } #endif @@ -87,22 +87,22 @@ void test_noexcept_optional_with_operator() // compile-time test ONxC onxC; ONxA onxA; ONx0 onx0; - - BOOST_STATIC_ASSERT( BOOST_NOEXCEPT_EXPR( ONx2() )); - BOOST_STATIC_ASSERT( BOOST_NOEXCEPT_EXPR( ONx2(std::move(onx2)) )); - BOOST_STATIC_ASSERT( BOOST_NOEXCEPT_EXPR( onx2 = ONx2() )); - - BOOST_STATIC_ASSERT( BOOST_NOEXCEPT_EXPR( ONxC() )); - BOOST_STATIC_ASSERT( BOOST_NOEXCEPT_EXPR( ONxC(std::move(onxC)) )); - BOOST_STATIC_ASSERT(!BOOST_NOEXCEPT_EXPR( onxC = ONxC() )); - - BOOST_STATIC_ASSERT( BOOST_NOEXCEPT_EXPR( ONxA() )); - BOOST_STATIC_ASSERT(!BOOST_NOEXCEPT_EXPR( ONxA(std::move(onxA)) )); - BOOST_STATIC_ASSERT(!BOOST_NOEXCEPT_EXPR( onxA = ONxA() )); - - BOOST_STATIC_ASSERT( BOOST_NOEXCEPT_EXPR( ONx0() )); - BOOST_STATIC_ASSERT(!BOOST_NOEXCEPT_EXPR( ONx0(std::move(onx0)) )); - BOOST_STATIC_ASSERT(!BOOST_NOEXCEPT_EXPR( onx0 = ONx0() )); + + static_assert( BOOST_NOEXCEPT_EXPR( ONx2() ), "ERROR"); + static_assert( BOOST_NOEXCEPT_EXPR( ONx2(std::move(onx2)) ), "ERROR"); + static_assert( BOOST_NOEXCEPT_EXPR( onx2 = ONx2() ), "ERROR"); + + static_assert( BOOST_NOEXCEPT_EXPR( ONxC() ), "ERROR"); + static_assert( BOOST_NOEXCEPT_EXPR( ONxC(std::move(onxC)) ), "ERROR"); + static_assert(!BOOST_NOEXCEPT_EXPR( onxC = ONxC() ), "ERROR"); + + static_assert( BOOST_NOEXCEPT_EXPR( ONxA() ), "ERROR"); + static_assert(!BOOST_NOEXCEPT_EXPR( ONxA(std::move(onxA)) ), "ERROR"); + static_assert(!BOOST_NOEXCEPT_EXPR( onxA = ONxA() ), "ERROR"); + + static_assert( BOOST_NOEXCEPT_EXPR( ONx0() ), "ERROR"); + static_assert(!BOOST_NOEXCEPT_EXPR( ONx0(std::move(onx0)) ), "ERROR"); + static_assert(!BOOST_NOEXCEPT_EXPR( onx0 = ONx0() ), "ERROR"); } #endif // !defined BOOST_NO_CXX11_NOEXCEPT @@ -112,5 +112,3 @@ int main() { return 0; } - - diff --git a/test/optional_test_path_assignment.cpp b/test/optional_test_path_assignment.cpp index 485e741..d8240d1 100644 --- a/test/optional_test_path_assignment.cpp +++ b/test/optional_test_path_assignment.cpp @@ -66,7 +66,7 @@ int main() optFs1 = optFs2; // the following still fails although it shouldn't - //BOOST_STATIC_ASSERT((std::is_copy_constructible>::value)); + //static_assert((std::is_copy_constructible>::value), "ERROR"); #endif #endif diff --git a/test/optional_test_ref_convert_assign_const_int_prevented.cpp b/test/optional_test_ref_convert_assign_const_int_prevented.cpp index e692475..153e6a8 100644 --- a/test/optional_test_ref_convert_assign_const_int_prevented.cpp +++ b/test/optional_test_ref_convert_assign_const_int_prevented.cpp @@ -26,7 +26,7 @@ int main() #ifdef BOOST_OPTIONAL_CONFIG_NO_PROPER_ASSIGN_FROM_CONST_INT test_converting_assignment(); #else - BOOST_STATIC_ASSERT_MSG(false, "EXPECTED TEST COMPILE-TIME FAILURE"); + static_assert(false, "EXPECTED TEST COMPILE-TIME FAILURE"); #endif return boost::report_errors(); } diff --git a/test/optional_test_sfinae_friendly_ctor.cpp b/test/optional_test_sfinae_friendly_ctor.cpp index c13bb2b..2eff2ff 100644 --- a/test/optional_test_sfinae_friendly_ctor.cpp +++ b/test/optional_test_sfinae_friendly_ctor.cpp @@ -21,29 +21,29 @@ using boost::optional; struct X {}; struct Y {}; - + struct Resource { explicit Resource(const X&) {} }; -BOOST_STATIC_ASSERT(( boost::is_constructible::value )); -BOOST_STATIC_ASSERT(( !boost::is_constructible::value )); +static_assert(( boost::is_constructible::value ), "ERROR"); +static_assert(( !boost::is_constructible::value ), "ERROR"); -BOOST_STATIC_ASSERT(( boost::is_constructible, const X&>::value )); -BOOST_STATIC_ASSERT(( !boost::is_constructible, const Y&>::value )); +static_assert(( boost::is_constructible, const X&>::value ), "ERROR"); +static_assert(( !boost::is_constructible, const Y&>::value ), "ERROR"); #ifndef BOOST_OPTIONAL_DETAIL_NO_SFINAE_FRIENDLY_CONSTRUCTORS -BOOST_STATIC_ASSERT(( boost::is_constructible< optional< optional >, optional >::value )); -BOOST_STATIC_ASSERT(( !boost::is_constructible< optional, optional< optional > >::value )); +static_assert(( boost::is_constructible< optional< optional >, optional >::value ), "ERROR"); +static_assert(( !boost::is_constructible< optional, optional< optional > >::value ), "ERROR"); -BOOST_STATIC_ASSERT(( boost::is_constructible< optional< optional >, const optional& >::value )); -BOOST_STATIC_ASSERT(( !boost::is_constructible< optional, const optional< optional >& >::value )); +static_assert(( boost::is_constructible< optional< optional >, const optional& >::value ), "ERROR"); +static_assert(( !boost::is_constructible< optional, const optional< optional >& >::value ), "ERROR"); -BOOST_STATIC_ASSERT(( boost::is_constructible, const optional&>::value )); -BOOST_STATIC_ASSERT(( !boost::is_constructible, const optional&>::value )); +static_assert(( boost::is_constructible, const optional&>::value ), "ERROR"); +static_assert(( !boost::is_constructible, const optional&>::value ), "ERROR"); #endif - + #endif int main() { }