mirror of
https://github.com/boostorg/dynamic_bitset.git
synced 2026-01-23 17:42:12 +00:00
Compare commits
6 Commits
boost-1.71
...
boost-1.76
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b59fc97a67 | ||
|
|
4a38853898 | ||
|
|
54b15ad171 | ||
|
|
ffff25ac00 | ||
|
|
3e0107909b | ||
|
|
8359a80feb |
@@ -34,7 +34,7 @@ namespace boost { namespace detail {
|
||||
#endif
|
||||
|
||||
//
|
||||
#if (defined __BORLANDC__ && BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))) \
|
||||
#if (defined BOOST_BORLANDC && BOOST_WORKAROUND(BOOST_BORLANDC, BOOST_TESTED_AT(0x564))) \
|
||||
|| (defined BOOST_NO_MEMBER_TEMPLATE_FRIENDS)
|
||||
#define BOOST_DYNAMIC_BITSET_DONT_USE_FRIENDS
|
||||
#endif
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#include <cstddef>
|
||||
#include "boost/config.hpp"
|
||||
#include "boost/detail/workaround.hpp"
|
||||
#include <boost/core/allocator_access.hpp>
|
||||
|
||||
#if ((defined(BOOST_MSVC) && (BOOST_MSVC >= 1600)) || (defined(__clang__) && defined(__c2__)) || (defined(BOOST_INTEL) && defined(_MSC_VER))) && (defined(_M_IX86) || defined(_M_X64))
|
||||
#include <intrin.h>
|
||||
@@ -30,6 +31,14 @@ namespace boost {
|
||||
namespace detail {
|
||||
namespace dynamic_bitset_impl {
|
||||
|
||||
template<class T>
|
||||
struct max_limit {
|
||||
BOOST_STATIC_CONSTEXPR T value = static_cast<T>(-1);
|
||||
};
|
||||
|
||||
template<class T>
|
||||
BOOST_CONSTEXPR_OR_CONST T max_limit<T>::value;
|
||||
|
||||
// Gives (read-)access to the object representation
|
||||
// of an object of type T (3.9p4). CANNOT be used
|
||||
// on a base sub-object
|
||||
@@ -229,14 +238,8 @@ namespace boost {
|
||||
|
||||
const allocator_type& alloc = v.get_allocator();
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
typedef std::allocator_traits<allocator_type> allocator_traits;
|
||||
|
||||
const typename allocator_traits::size_type alloc_max =
|
||||
allocator_traits::max_size(alloc);
|
||||
#else
|
||||
const typename allocator_type::size_type alloc_max = alloc.max_size();
|
||||
#endif
|
||||
typename boost::allocator_size_type<allocator_type>::type alloc_max =
|
||||
boost::allocator_max_size(alloc);
|
||||
|
||||
const typename T::size_type container_max = v.max_size();
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include <string>
|
||||
#include <stdexcept>
|
||||
#include <algorithm>
|
||||
#include <iterator> // used to implement append(Iter, Iter)
|
||||
#include <vector>
|
||||
#include <climits> // for CHAR_BIT
|
||||
|
||||
@@ -43,12 +44,11 @@
|
||||
#include "boost/dynamic_bitset_fwd.hpp"
|
||||
#include "boost/dynamic_bitset/detail/dynamic_bitset.hpp"
|
||||
#include "boost/dynamic_bitset/detail/lowest_bit.hpp"
|
||||
#include "boost/detail/iterator.hpp" // used to implement append(Iter, Iter)
|
||||
#include "boost/move/move.hpp"
|
||||
#include "boost/limits.hpp"
|
||||
#include "boost/static_assert.hpp"
|
||||
#include "boost/utility/addressof.hpp"
|
||||
#include "boost/detail/no_exceptions_support.hpp"
|
||||
#include "boost/core/addressof.hpp"
|
||||
#include "boost/core/no_exceptions_support.hpp"
|
||||
#include "boost/throw_exception.hpp"
|
||||
#include "boost/functional/hash/hash.hpp"
|
||||
|
||||
@@ -247,7 +247,7 @@ public:
|
||||
{
|
||||
assert(first != last);
|
||||
block_width_type r = count_extra_bits();
|
||||
std::size_t d = boost::detail::distance(first, last);
|
||||
std::size_t d = std::distance(first, last);
|
||||
m_bits.reserve(num_blocks() + d);
|
||||
if (r == 0) {
|
||||
for( ; first != last; ++first)
|
||||
@@ -267,7 +267,7 @@ public:
|
||||
void append(BlockInputIterator first, BlockInputIterator last) // strong guarantee
|
||||
{
|
||||
if (first != last) {
|
||||
typename detail::iterator_traits<BlockInputIterator>::iterator_category cat;
|
||||
typename std::iterator_traits<BlockInputIterator>::iterator_category cat;
|
||||
m_append(first, last, cat);
|
||||
}
|
||||
}
|
||||
@@ -375,6 +375,7 @@ private:
|
||||
void m_zero_unused_bits();
|
||||
bool m_check_invariants() const;
|
||||
|
||||
static bool m_not_empty(Block x){ return x != Block(0); };
|
||||
size_type m_do_find_from(size_type first_block) const;
|
||||
|
||||
block_width_type count_extra_bits() const BOOST_NOEXCEPT { return bit_index(size()); }
|
||||
@@ -384,7 +385,7 @@ private:
|
||||
static Block bit_mask(size_type first, size_type last) BOOST_NOEXCEPT
|
||||
{
|
||||
Block res = (last == bits_per_block - 1)
|
||||
? static_cast<Block>(~0)
|
||||
? detail::dynamic_bitset_impl::max_limit<Block>::value
|
||||
: ((Block(1) << (last + 1)) - 1);
|
||||
res ^= (Block(1) << first) - 1;
|
||||
return res;
|
||||
@@ -406,7 +407,7 @@ private:
|
||||
}
|
||||
inline static Block set_block_full(Block) BOOST_NOEXCEPT
|
||||
{
|
||||
return static_cast<Block>(~0);
|
||||
return detail::dynamic_bitset_impl::max_limit<Block>::value;
|
||||
}
|
||||
inline static Block reset_block_partial(Block block, size_type first,
|
||||
size_type last) BOOST_NOEXCEPT
|
||||
@@ -764,7 +765,7 @@ resize(size_type num_bits, bool value) // strong guarantee
|
||||
const size_type old_num_blocks = num_blocks();
|
||||
const size_type required_blocks = calc_num_blocks(num_bits);
|
||||
|
||||
const block_type v = value? ~Block(0) : Block(0);
|
||||
const block_type v = value? detail::dynamic_bitset_impl::max_limit<Block>::value : Block(0);
|
||||
|
||||
if (required_blocks != old_num_blocks) {
|
||||
m_bits.resize(required_blocks, v); // s.g. (copy)
|
||||
@@ -1045,7 +1046,7 @@ template <typename Block, typename Allocator>
|
||||
dynamic_bitset<Block, Allocator>&
|
||||
dynamic_bitset<Block, Allocator>::set()
|
||||
{
|
||||
std::fill(m_bits.begin(), m_bits.end(), static_cast<Block>(~0));
|
||||
std::fill(m_bits.begin(), m_bits.end(), detail::dynamic_bitset_impl::max_limit<Block>::value);
|
||||
m_zero_unused_bits();
|
||||
return *this;
|
||||
}
|
||||
@@ -1138,7 +1139,7 @@ bool dynamic_bitset<Block, Allocator>::all() const
|
||||
}
|
||||
|
||||
const block_width_type extra_bits = count_extra_bits();
|
||||
block_type const all_ones = static_cast<Block>(~0);
|
||||
block_type const all_ones = detail::dynamic_bitset_impl::max_limit<Block>::value;
|
||||
|
||||
if (extra_bits == 0) {
|
||||
for (size_type i = 0, e = num_blocks(); i < e; ++i) {
|
||||
@@ -1441,15 +1442,14 @@ bool dynamic_bitset<Block, Allocator>::intersects(const dynamic_bitset & b) cons
|
||||
// look for the first bit "on", starting
|
||||
// from the block with index first_block
|
||||
//
|
||||
|
||||
template <typename Block, typename Allocator>
|
||||
typename dynamic_bitset<Block, Allocator>::size_type
|
||||
dynamic_bitset<Block, Allocator>::m_do_find_from(size_type first_block) const
|
||||
{
|
||||
size_type i = first_block;
|
||||
|
||||
// skip null blocks
|
||||
while (i < num_blocks() && m_bits[i] == 0)
|
||||
++i;
|
||||
size_type i = std::distance(m_bits.begin(),
|
||||
std::find_if(m_bits.begin() + first_block, m_bits.end(), m_not_empty) );
|
||||
|
||||
if (i >= num_blocks())
|
||||
return npos; // not found
|
||||
@@ -2107,7 +2107,7 @@ bool dynamic_bitset<Block, Allocator>::m_check_invariants() const
|
||||
{
|
||||
const block_width_type extra_bits = count_extra_bits();
|
||||
if (extra_bits > 0) {
|
||||
const block_type mask = block_type(~0) << extra_bits;
|
||||
const block_type mask = detail::dynamic_bitset_impl::max_limit<Block>::value << extra_bits;
|
||||
if ((m_highest_block() & mask) != 0)
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
#define BOOST_DYNAMIC_BITSET_SERIALIZATION_HPP
|
||||
|
||||
#include "boost/dynamic_bitset/dynamic_bitset.hpp"
|
||||
#include <boost/serialization/vector.hpp>
|
||||
#include <boost/core/nvp.hpp>
|
||||
|
||||
namespace boost {
|
||||
|
||||
@@ -23,8 +23,8 @@ namespace boost {
|
||||
public:
|
||||
template <typename Ar>
|
||||
static void serialize(Ar& ar, dynamic_bitset<Block, Allocator>& bs, unsigned) {
|
||||
ar & serialization::make_nvp("m_num_bits", bs.m_num_bits)
|
||||
& serialization::make_nvp("m_bits", bs.m_bits);
|
||||
ar & boost::make_nvp("m_num_bits", bs.m_num_bits)
|
||||
& boost::make_nvp("m_bits", bs.m_bits);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ template <typename Block>
|
||||
inline bool nth_bit(Block num, std::size_t n)
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
#ifdef __BORLANDC__
|
||||
#ifdef BOOST_BORLANDC
|
||||
// Borland deduces Block as a const qualified type,
|
||||
// and thus finds numeric_limits<Block> to be zero :(
|
||||
// (though not directly relevant here, see also
|
||||
|
||||
@@ -191,7 +191,7 @@ void run_test_cases( BOOST_EXPLICIT_TEMPLATE_TYPE(Block) )
|
||||
// (in Tests::stream_extractor instantiation)
|
||||
|
||||
|
||||
#if !(defined __BORLANDC__ \
|
||||
#if !(defined BOOST_BORLANDC \
|
||||
&& BOOST_WORKAROUND(BOOST_RWSTD_VER, BOOST_TESTED_AT(0x20101)))
|
||||
// Borland 5.5.1 with RW library crashes
|
||||
// empty string
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
# define BOOST_DYNAMIC_BITSET_NO_WCHAR_T_TESTS
|
||||
#endif
|
||||
|
||||
#include <boost/serialization/vector.hpp>
|
||||
#include <boost/archive/binary_oarchive.hpp>
|
||||
#include <boost/archive/binary_iarchive.hpp>
|
||||
#include <boost/archive/xml_oarchive.hpp>
|
||||
|
||||
Reference in New Issue
Block a user