From 12dfcea22f8f2f255ebbd13731cfdf80b0ed4f22 Mon Sep 17 00:00:00 2001 From: Gennaro Prota Date: Wed, 10 Sep 2025 17:37:56 +0200 Subject: [PATCH] Get rid of BOOST_STATIC_ASSERT() and BOOST_STATIC_CONSTANT() Reason: They are no longer necessary, given that we require C++11 now. --- CMakeLists.txt | 3 +- build.jam | 1 - .../boost/dynamic_bitset/dynamic_bitset.hpp | 32 ++++--------------- test/bitset_test.hpp | 2 +- 4 files changed, 8 insertions(+), 30 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b1630cb..e31af44 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -46,7 +46,7 @@ if (BOOST_DYNAMIC_BITSET_IS_ROOT) # If BOOST_SRC_DIR is valid, fallback to find_package set(CMAKE_FOLDER Dependencies) - set(BOOST_INCLUDE_LIBRARIES assert config container_hash core integer move static_assert throw_exception) + set(BOOST_INCLUDE_LIBRARIES assert config container_hash core integer move throw_exception) set(BOOST_EXCLUDE_LIBRARIES dynamic_bitset) set(PREV_BUILD_TESTING ${BUILD_TESTING}) set(BUILD_TESTING OFF CACHE BOOL "Build the tests." FORCE) @@ -64,7 +64,6 @@ target_link_libraries(boost_dynamic_bitset Boost::core Boost::integer Boost::move - Boost::static_assert Boost::throw_exception ) diff --git a/build.jam b/build.jam index 6e5741b..67e5e65 100644 --- a/build.jam +++ b/build.jam @@ -12,7 +12,6 @@ constant boost_dependencies : /boost/core//boost_core /boost/integer//boost_integer /boost/move//boost_move - /boost/static_assert//boost_static_assert /boost/throw_exception//boost_throw_exception ; project /boost/dynamic_bitset diff --git a/include/boost/dynamic_bitset/dynamic_bitset.hpp b/include/boost/dynamic_bitset/dynamic_bitset.hpp index f6bbd9e..42cf459 100644 --- a/include/boost/dynamic_bitset/dynamic_bitset.hpp +++ b/include/boost/dynamic_bitset/dynamic_bitset.hpp @@ -23,7 +23,6 @@ #include "boost/dynamic_bitset/detail/dynamic_bitset.hpp" #include "boost/dynamic_bitset_fwd.hpp" #include "boost/limits.hpp" -#include "boost/static_assert.hpp" #include #include #include @@ -81,8 +80,8 @@ class const_bit_iterator; template< typename Block, typename AllocatorOrContainer > class dynamic_bitset { - BOOST_STATIC_ASSERT( (bool)detail::dynamic_bitset_impl::allowed_block_type< Block >::value ); - BOOST_STATIC_ASSERT( std::is_same< Block, typename AllocatorOrContainer::value_type >::value ); + static_assert( (bool)detail::dynamic_bitset_impl::allowed_block_type< Block >::value, "Block type not allowed" ); + static_assert( std::is_same< Block, typename AllocatorOrContainer::value_type >::value, "Block is not the same type as AllocatorOrContainer::value_type" ); public: //! The same type as `Block`. @@ -113,11 +112,11 @@ public: //! values, excluding any padding bits. Numerically equal to //! `std::numeric_limits< Block >::digits`. // ----------------------------------------------------------------------- - BOOST_STATIC_CONSTANT( int, bits_per_block = std::numeric_limits< Block >::digits ); + static constexpr int bits_per_block = std::numeric_limits< Block >::digits; //! The maximum value of `size_type`. // ----------------------------------------------------------------------- - BOOST_STATIC_CONSTANT( size_type, npos = static_cast< size_type >( -1 ) ); + static constexpr size_type npos = static_cast< size_type >( -1 ); //! A proxy class to simulate lvalues of bit type. //! @@ -1253,7 +1252,7 @@ public: friend class serialize_impl; private: - BOOST_STATIC_CONSTANT( int, ulong_width = std::numeric_limits< unsigned long >::digits ); + static constexpr int ulong_width = std::numeric_limits< unsigned long >::digits; dynamic_bitset & range_operation( size_type pos, size_type len, Block ( *partial_block_operation )( Block, size_type, size_type ), Block ( *full_block_operation )( Block ) ); void m_zero_unused_bits(); @@ -1356,7 +1355,7 @@ public: void decrement(); void add( typename Iterator::difference_type n ); - BOOST_STATIC_CONSTANT( int, bits_per_block = std::numeric_limits< typename Iterator::value_type >::digits ); + static constexpr int bits_per_block = std::numeric_limits< typename Iterator::value_type >::digits; Iterator m_block_iterator; int m_bit_index = 0; }; @@ -1406,25 +1405,6 @@ public: const_reference operator[]( difference_type n ) const; }; -#if ! defined BOOST_NO_INCLASS_MEMBER_INITIALIZATION - -template< typename Block, typename AllocatorOrContainer > -const int - dynamic_bitset< Block, AllocatorOrContainer >::bits_per_block; - -template< typename Block, typename AllocatorOrContainer > -const typename dynamic_bitset< Block, AllocatorOrContainer >::size_type - dynamic_bitset< Block, AllocatorOrContainer >::npos; - -template< typename Block, typename AllocatorOrContainer > -const int - dynamic_bitset< Block, AllocatorOrContainer >::ulong_width; - -template< typename Container > -const int - bit_iterator_base< Container >::bits_per_block; -#endif - //! Compares two bitsets. //! //! \return diff --git a/test/bitset_test.hpp b/test/bitset_test.hpp index 1dca01d..a0564c3 100644 --- a/test/bitset_test.hpp +++ b/test/bitset_test.hpp @@ -134,7 +134,7 @@ template< typename Bitset > struct bitset_test { typedef typename Bitset::block_type Block; - BOOST_STATIC_CONSTANT( int, bits_per_block = Bitset::bits_per_block ); + static constexpr int bits_per_block = Bitset::bits_per_block; // from unsigned long //