Skip to content

Commit

Permalink
Drop dependency on Boost.StaticAssert
Browse files Browse the repository at this point in the history
  • Loading branch information
akrzemi1 committed Oct 16, 2024
1 parent b2c7f93 commit e601f1e
Show file tree
Hide file tree
Showing 11 changed files with 78 additions and 82 deletions.
3 changes: 1 addition & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -21,7 +21,6 @@ target_link_libraries(boost_optional
Boost::assert
Boost::config
Boost::core
Boost::static_assert
Boost::throw_exception
Boost::type_traits
)
Expand Down
2 changes: 0 additions & 2 deletions build.jam
Original file line number Diff line number Diff line change
Expand Up @@ -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 ;

Expand All @@ -22,4 +21,3 @@ explicit

call-if : boost-library optional
;

3 changes: 2 additions & 1 deletion doc/92_relnotes.qbk
Original file line number Diff line number Diff line change
Expand Up @@ -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].
Expand Down
12 changes: 6 additions & 6 deletions include/boost/optional/detail/optional_reference_spec.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,16 @@ template <class From>
void prevent_binding_rvalue()
{
#ifndef BOOST_OPTIONAL_CONFIG_ALLOW_BINDING_TO_RVALUES
BOOST_STATIC_ASSERT_MSG(boost::is_lvalue_reference<From>::value,
"binding rvalue references to optional lvalue references is disallowed");
static_assert(boost::is_lvalue_reference<From>::value,
"binding rvalue references to optional lvalue references is disallowed");
#endif
}

template <class T>
BOOST_DEDUCED_TYPENAME boost::remove_reference<T>::type& forward_reference(T&& r)
{
BOOST_STATIC_ASSERT_MSG(boost::is_lvalue_reference<T>::value,
"binding rvalue references to optional lvalue references is disallowed");
static_assert(boost::is_lvalue_reference<T>::value,
"binding rvalue references to optional lvalue references is disallowed");
return optional_detail::forward<T>(r);
}

Expand Down Expand Up @@ -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<From>::value,
"binding const lvalue references to integral types is disabled in this compiler");
static_assert(!is_const_integral<From>::value,
"binding const lvalue references to integral types is disabled in this compiler");
#endif
#endif
}
Expand Down
4 changes: 2 additions & 2 deletions include/boost/optional/optional.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1053,7 +1053,7 @@ class optional
template<class T>
class optional<T&&>
{
BOOST_STATIC_ASSERT_MSG(sizeof(T) == 0, "Optional rvalue references are illegal.");
static_assert(sizeof(T) == 0, "Optional rvalue references are illegal.");
} ;

} // namespace boost
Expand Down Expand Up @@ -1163,7 +1163,7 @@ template<class CharType, class CharTrait>
std::basic_ostream<CharType, CharTrait>&
operator<<(std::basic_ostream<CharType, CharTrait>& os, optional_detail::optional_tag const&)
{
BOOST_STATIC_ASSERT_MSG(sizeof(CharType) == 0, "If you want to output boost::optional, include header <boost/optional/optional_io.hpp>");
static_assert(sizeof(CharType) == 0, "If you want to output boost::optional, include header <boost/optional/optional_io.hpp>");
return os;
}

Expand Down
6 changes: 3 additions & 3 deletions test/optional_test_convert_assign.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<optional<bool>&, bool>::value));
BOOST_STATIC_ASSERT((boost::is_assignable<optional<bool>&, implicit_bool_conv>::value));
BOOST_STATIC_ASSERT((! boost::is_assignable<optional<bool>&, explicit_bool_conv>::value));
static_assert((boost::is_assignable<optional<bool>&, bool>::value), "ERROR");
static_assert((boost::is_assignable<optional<bool>&, implicit_bool_conv>::value), "ERROR");
static_assert((! boost::is_assignable<optional<bool>&, explicit_bool_conv>::value), "ERROR");
#endif
}

Expand Down
16 changes: 8 additions & 8 deletions test/optional_test_convert_from_T.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ struct superconv
{
#ifndef BOOST_OPTIONAL_DETAIL_NO_RVALUE_REFERENCES
template <typename T>
superconv(T&&) { BOOST_STATIC_ASSERT(sizeof(T) == 0); }
superconv(T&&) { static_assert(sizeof(T) == 0, "ERROR"); }
#else
template <typename T>
superconv(const T&) { BOOST_STATIC_ASSERT(sizeof(T) == 0); }
superconv(const T&) { static_assert(sizeof(T) == 0, "ERROR"); }
template <typename T>
superconv( T&) { BOOST_STATIC_ASSERT(sizeof(T) == 0); }
superconv( T&) { static_assert(sizeof(T) == 0, "ERROR"); }
#endif

superconv() {}
};

Expand All @@ -52,19 +52,19 @@ void test_optional_optional_T()
{
optional<int> oi1 (1), oiN;
optional< optional<int> > 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();
}
86 changes: 42 additions & 44 deletions test/optional_test_noexcept_move.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<NothrowBoth>::value);
BOOST_STATIC_ASSERT(::boost::is_nothrow_move_assignable<NothrowBoth>::value);
BOOST_STATIC_ASSERT(::boost::is_nothrow_move_constructible<NothrowCtor>::value);
BOOST_STATIC_ASSERT(!::boost::is_nothrow_move_assignable<NothrowCtor>::value);
BOOST_STATIC_ASSERT(!::boost::is_nothrow_move_constructible<NothrowAssign>::value);
BOOST_STATIC_ASSERT(::boost::is_nothrow_move_assignable<NothrowAssign>::value);
BOOST_STATIC_ASSERT(!::boost::is_nothrow_move_constructible<NothrowNone>::value);
BOOST_STATIC_ASSERT(!::boost::is_nothrow_move_assignable<NothrowNone>::value);
static_assert(::boost::is_nothrow_move_constructible<NothrowBoth>::value, "ERROR");
static_assert(::boost::is_nothrow_move_assignable<NothrowBoth>::value, "ERROR");

static_assert(::boost::is_nothrow_move_constructible<NothrowCtor>::value, "ERROR");
static_assert(!::boost::is_nothrow_move_assignable<NothrowCtor>::value, "ERROR");

static_assert(!::boost::is_nothrow_move_constructible<NothrowAssign>::value, "ERROR");
static_assert(::boost::is_nothrow_move_assignable<NothrowAssign>::value, "ERROR");

static_assert(!::boost::is_nothrow_move_constructible<NothrowNone>::value, "ERROR");
static_assert(!::boost::is_nothrow_move_assignable<NothrowNone>::value, "ERROR");
}

void test_noexcept_on_optional_with_type_traits() // this is a compile-time test
{
BOOST_STATIC_ASSERT(::boost::is_nothrow_move_constructible<optional<NothrowBoth> >::value);
BOOST_STATIC_ASSERT(::boost::is_nothrow_move_assignable<optional<NothrowBoth> >::value);
BOOST_STATIC_ASSERT(BOOST_NOEXCEPT_EXPR(optional<NothrowBoth>()));
BOOST_STATIC_ASSERT(::boost::is_nothrow_move_constructible<optional<NothrowCtor> >::value);
BOOST_STATIC_ASSERT(!::boost::is_nothrow_move_assignable<optional<NothrowCtor> >::value);
BOOST_STATIC_ASSERT(BOOST_NOEXCEPT_EXPR(optional<NothrowCtor>()));
BOOST_STATIC_ASSERT(!::boost::is_nothrow_move_constructible<optional<NothrowAssign> >::value);
BOOST_STATIC_ASSERT(!::boost::is_nothrow_move_assignable<optional<NothrowAssign> >::value);
BOOST_STATIC_ASSERT(BOOST_NOEXCEPT_EXPR(optional<NothrowAssign>()));
BOOST_STATIC_ASSERT(!::boost::is_nothrow_move_constructible<optional<NothrowNone> >::value);
BOOST_STATIC_ASSERT(!::boost::is_nothrow_move_assignable<optional<NothrowNone> >::value);
BOOST_STATIC_ASSERT(BOOST_NOEXCEPT_EXPR(optional<NothrowNone>()));
static_assert(::boost::is_nothrow_move_constructible<optional<NothrowBoth> >::value, "ERROR");
static_assert(::boost::is_nothrow_move_assignable<optional<NothrowBoth> >::value, "ERROR");
static_assert(BOOST_NOEXCEPT_EXPR(optional<NothrowBoth>()), "ERROR");

static_assert(::boost::is_nothrow_move_constructible<optional<NothrowCtor> >::value, "ERROR");
static_assert(!::boost::is_nothrow_move_assignable<optional<NothrowCtor> >::value, "ERROR");
static_assert(BOOST_NOEXCEPT_EXPR(optional<NothrowCtor>()), "ERROR");

static_assert(!::boost::is_nothrow_move_constructible<optional<NothrowAssign> >::value, "ERROR");
static_assert(!::boost::is_nothrow_move_assignable<optional<NothrowAssign> >::value, "ERROR");
static_assert(BOOST_NOEXCEPT_EXPR(optional<NothrowAssign>()), "ERROR");

static_assert(!::boost::is_nothrow_move_constructible<optional<NothrowNone> >::value, "ERROR");
static_assert(!::boost::is_nothrow_move_assignable<optional<NothrowNone> >::value, "ERROR");
static_assert(BOOST_NOEXCEPT_EXPR(optional<NothrowNone>()), "ERROR");
}
#endif

Expand All @@ -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
Expand All @@ -112,5 +112,3 @@ int main()
{
return 0;
}


2 changes: 1 addition & 1 deletion test/optional_test_path_assignment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ int main()
optFs1 = optFs2;

// the following still fails although it shouldn't
//BOOST_STATIC_ASSERT((std::is_copy_constructible<boost::optional<Path>>::value));
//static_assert((std::is_copy_constructible<boost::optional<Path>>::value), "ERROR");

#endif
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ int main()
#ifdef BOOST_OPTIONAL_CONFIG_NO_PROPER_ASSIGN_FROM_CONST_INT
test_converting_assignment<const int, const int>();
#else
BOOST_STATIC_ASSERT_MSG(false, "EXPECTED TEST COMPILE-TIME FAILURE");
static_assert(false, "EXPECTED TEST COMPILE-TIME FAILURE");
#endif
return boost::report_errors();
}
24 changes: 12 additions & 12 deletions test/optional_test_sfinae_friendly_ctor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,29 +21,29 @@ using boost::optional;

struct X {};
struct Y {};

struct Resource
{
explicit Resource(const X&) {}
};

BOOST_STATIC_ASSERT(( boost::is_constructible<Resource, const X&>::value ));
BOOST_STATIC_ASSERT(( !boost::is_constructible<Resource, const Y&>::value ));
static_assert(( boost::is_constructible<Resource, const X&>::value ), "ERROR");
static_assert(( !boost::is_constructible<Resource, const Y&>::value ), "ERROR");

BOOST_STATIC_ASSERT(( boost::is_constructible<optional<Resource>, const X&>::value ));
BOOST_STATIC_ASSERT(( !boost::is_constructible<optional<Resource>, const Y&>::value ));
static_assert(( boost::is_constructible<optional<Resource>, const X&>::value ), "ERROR");
static_assert(( !boost::is_constructible<optional<Resource>, const Y&>::value ), "ERROR");

#ifndef BOOST_OPTIONAL_DETAIL_NO_SFINAE_FRIENDLY_CONSTRUCTORS
BOOST_STATIC_ASSERT(( boost::is_constructible< optional< optional<int> >, optional<int> >::value ));
BOOST_STATIC_ASSERT(( !boost::is_constructible< optional<int>, optional< optional<int> > >::value ));
static_assert(( boost::is_constructible< optional< optional<int> >, optional<int> >::value ), "ERROR");
static_assert(( !boost::is_constructible< optional<int>, optional< optional<int> > >::value ), "ERROR");

BOOST_STATIC_ASSERT(( boost::is_constructible< optional< optional<int> >, const optional<int>& >::value ));
BOOST_STATIC_ASSERT(( !boost::is_constructible< optional<int>, const optional< optional<int> >& >::value ));
static_assert(( boost::is_constructible< optional< optional<int> >, const optional<int>& >::value ), "ERROR");
static_assert(( !boost::is_constructible< optional<int>, const optional< optional<int> >& >::value ), "ERROR");

BOOST_STATIC_ASSERT(( boost::is_constructible<optional<Resource>, const optional<X>&>::value ));
BOOST_STATIC_ASSERT(( !boost::is_constructible<optional<Resource>, const optional<Y>&>::value ));
static_assert(( boost::is_constructible<optional<Resource>, const optional<X>&>::value ), "ERROR");
static_assert(( !boost::is_constructible<optional<Resource>, const optional<Y>&>::value ), "ERROR");
#endif

#endif

int main() { }

0 comments on commit e601f1e

Please sign in to comment.