Compare commits

..

11 Commits

Author SHA1 Message Date
nobody
5d0ce5eabf This commit was manufactured by cvs2svn to create tag
'Version_1_29_0'.

[SVN r15904]
2002-10-11 15:17:55 +00:00
Jeremy Siek
8764797683 Removed __BORLANDC__ from the #if around the basic_string
constructor. Luckily the fix by GP for g++ also fixes Borland. [JGS]


[SVN r15806]
2002-10-08 15:51:35 +00:00
Jeremy Siek
b5db54b395 fixed friend issue in dump_to_string and added this-> in set_block_
[SVN r15794]
2002-10-07 22:14:03 +00:00
Jeremy Siek
cb0d5a3eb8 added from_block_range
[SVN r15789]
2002-10-07 19:01:06 +00:00
Jeremy Siek
7f2261c169 added this-> in more places
[SVN r15788]
2002-10-07 18:58:17 +00:00
Jeremy Siek
9313c72a66 added test for from_block_range
[SVN r15783]
2002-10-07 18:20:22 +00:00
Jeremy Siek
ef14e2fc84 made from_block_range a non-member
[SVN r15782]
2002-10-07 18:07:43 +00:00
Jeremy Siek
32d0ac3a5c applied () workaround for basic_string constructor
[SVN r15774]
2002-10-07 15:48:44 +00:00
Jeremy Siek
13bc913224 some small fixes
[SVN r15748]
2002-10-06 03:31:20 +00:00
Jeremy Siek
618100947c some bug fixes
[SVN r15717]
2002-10-04 19:41:39 +00:00
nobody
7153a28bf7 This commit was manufactured by cvs2svn to create branch 'RC_1_29_0'.
[SVN r15460]
2002-09-19 20:49:39 +00:00
7 changed files with 118 additions and 152 deletions

View File

@@ -66,7 +66,7 @@ struct bitset_test {
if (! (str[i] == '0' || str[i] == '1'))
any_non_zero_or_one = true;
if (any_non_zero_or_one) {
// Input does not satisfy precondition.
// Input does not satisfy precondition.
} else {
// Construct an object, initializing the first M bit position to
// values determined from the corresponding characters in the
@@ -97,10 +97,10 @@ struct bitset_test {
Bitset bset(blocks.begin(), blocks.end());
std::size_t n = blocks.size();
for (std::size_t b = 0; b < n; ++b) {
for (std::size_t i = 0; i < sizeof(Block) * CHAR_BIT; ++i) {
std::size_t bit = b * sizeof(Block) * CHAR_BIT + i;
BOOST_CHECK(bset[bit] == nth_bit(blocks[b], i));
}
for (std::size_t i = 0; i < sizeof(Block) * CHAR_BIT; ++i) {
std::size_t bit = b * sizeof(Block) * CHAR_BIT + i;
BOOST_CHECK(bset[bit] == nth_bit(blocks[b], i));
}
}
}
{
@@ -108,10 +108,10 @@ struct bitset_test {
boost::from_block_range(blocks.begin(), blocks.end(), bset);
std::size_t n = blocks.size();
for (std::size_t b = 0; b < n; ++b) {
for (std::size_t i = 0; i < sizeof(Block) * CHAR_BIT; ++i) {
std::size_t bit = b * sizeof(Block) * CHAR_BIT + i;
BOOST_CHECK(bset[bit] == nth_bit(blocks[b], i));
}
for (std::size_t i = 0; i < sizeof(Block) * CHAR_BIT; ++i) {
std::size_t bit = b * sizeof(Block) * CHAR_BIT + i;
BOOST_CHECK(bset[bit] == nth_bit(blocks[b], i));
}
}
}
}
@@ -531,15 +531,15 @@ struct bitset_test {
{
if (a.is_subset_of(b)) {
for (std::size_t I = 0; I < a.size(); ++I)
if (a[I])
BOOST_CHECK(b[I]);
if (a[I])
BOOST_CHECK(b[I]);
} else {
bool is_subset = true;
for (std::size_t I = 0; I < a.size(); ++I)
if (a[I] && !b[I]) {
is_subset = false;
break;
}
if (a[I] && !b[I]) {
is_subset = false;
break;
}
BOOST_CHECK(is_subset == false);
}
}
@@ -548,16 +548,16 @@ struct bitset_test {
{
if (a.is_proper_subset_of(b)) {
for (std::size_t I = 0; I < a.size(); ++I)
if (a[I])
BOOST_CHECK(b[I]);
if (a[I])
BOOST_CHECK(b[I]);
BOOST_CHECK(a.count() < b.count());
} else {
bool is_subset = true;
for (std::size_t I = 0; I < a.size(); ++I)
if (a[I] && !b[I]) {
is_subset = false;
break;
}
if (a[I] && !b[I]) {
is_subset = false;
break;
}
BOOST_CHECK(is_subset == false || a.count() >= b.count());
}
}

View File

@@ -1,10 +1,3 @@
// (C) Copyright Jeremy Siek 2001.
// Permission to copy, use, modify, sell and distribute this software
// is granted provided this copyright notice appears in all
// copies. This software is provided "as is" without express or
// implied warranty, and with no claim as to its suitability for any
// purpose.
#include <iostream>
#include <fstream>
#include <cmath> // for pow
@@ -36,7 +29,7 @@ void run_test_cases()
std::size_t N, ul_size = CHAR_BIT * sizeof(unsigned long),
block_size = CHAR_BIT * sizeof(Block);
unsigned long numbers[] = { 0, 40247,
std::numeric_limits<unsigned long>::max() };
std::numeric_limits<unsigned long>::max() };
//=====================================================================
// Test construction from unsigned long

View File

@@ -1,10 +1,3 @@
// (C) Copyright Jeremy Siek 2001.
// Permission to copy, use, modify, sell and distribute this software
// is granted provided this copyright notice appears in all
// copies. This software is provided "as is" without express or
// implied warranty, and with no claim as to its suitability for any
// purpose.
#include <iostream>
#include <fstream>
#include <cmath> // for pow
@@ -237,4 +230,3 @@ test_main(int argc, char*[])
run_test_cases<unsigned long>();
return EXIT_SUCCESS;
}

View File

@@ -1,10 +1,3 @@
// (C) Copyright Jeremy Siek 2001.
// Permission to copy, use, modify, sell and distribute this software
// is granted provided this copyright notice appears in all
// copies. This software is provided "as is" without express or
// implied warranty, and with no claim as to its suitability for any
// purpose.
#include <iostream>
#include <fstream>
#include <cmath> // for pow

View File

@@ -1,4 +1,4 @@
// (C) Copyright Chuck Allison and Jeremy Siek 2001, 2002.
// (C) Copyright Chuck Allison and Jeremy Siek 2001, 2002.
//
// Permission to copy, use, modify, sell and distribute this software
// is granted provided this copyright notice appears in all
@@ -45,7 +45,7 @@ namespace boost {
template <typename Block, typename Allocator>
class dynamic_bitset_base :
class dynamic_bitset_base :
#ifdef BOOST_DYN_BITSET_USE_FRIENDS
protected
#else
@@ -77,7 +77,7 @@ namespace boost {
this->m_alloc.deallocate(m_bits, m_num_blocks);
}
#ifdef BOOST_DYN_BITSET_USE_FRIENDS
protected:
protected:
#endif
Block* m_bits;
size_type m_num_bits;
@@ -87,7 +87,7 @@ namespace boost {
static size_type offset(size_type bit){ return bit % bits_per_block; } // [gps]
static Block mask1(size_type bit) { return Block(1) << offset(bit); }
static Block mask0(size_type bit) { return ~(Block(1) << offset(bit)); }
static size_type calc_num_blocks(size_type num_bits)
static size_type calc_num_blocks(size_type num_bits)
{ return (num_bits + bits_per_block - 1) / bits_per_block; }
};
@@ -127,13 +127,13 @@ namespace boost {
{
// Automatically generated by GPTableGen.exe v.1.0
//
0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4, 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4, 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, 4, 5, 5, 6, 5, 6, 6, 7, 5, 6, 6, 7, 6, 7, 7, 8
};
@@ -142,26 +142,26 @@ namespace boost {
template <typename BlockInputIterator>
std::size_t initial_num_blocks(BlockInputIterator first,
BlockInputIterator last,
std::input_iterator_tag)
BlockInputIterator last,
std::input_iterator_tag)
{
return 0;
}
template <typename BlockForwardIterator>
std::size_t initial_num_blocks(BlockForwardIterator first,
BlockForwardIterator last,
std::forward_iterator_tag)
BlockForwardIterator last,
std::forward_iterator_tag)
{
std::size_t n = 0;
while (first != last)
++first, ++n;
++first, ++n;
return n;
}
template <typename BlockInputIterator>
std::size_t initial_num_blocks(BlockInputIterator first,
BlockInputIterator last)
BlockInputIterator last)
{
typename detail::iterator_traits<BlockInputIterator>::iterator_category cat;
return initial_num_blocks(first, last, cat);

View File

@@ -1,4 +1,4 @@
// (C) Copyright Chuck Allison and Jeremy Siek 2001, 2002.
// (C) Copyright Chuck Allison and Jeremy Siek 2001, 2002.
//
// Permission to copy, use, modify, sell and distribute this software
// is granted provided this copyright notice appears in all
@@ -8,8 +8,6 @@
// With optimizations, bug fixes, and improvements by Gennaro Prota.
// See http://www.boost.org/libs/dynamic_bitset for documentation.
// -------------------------------------
// CHANGE LOG:
//
@@ -48,8 +46,8 @@
#define BOOST_OLD_IOSTREAMS
#endif
#if defined(BOOST_MSVC) && BOOST_MSVC <= 1300
#ifdef BOOST_MSVC
// in certain situations VC++ requires a redefinition of
// default template arguments, in contrast with 14.1/12
//
@@ -66,7 +64,7 @@ namespace boost {
template <typename Block, typename Allocator>
#endif
class dynamic_bitset :
class dynamic_bitset :
#ifdef BOOST_DYN_BITSET_USE_FRIENDS
private
#else
@@ -88,7 +86,7 @@ public:
friend class dynamic_bitset<Block, Allocator>;
dynamic_bitset* bs;
size_type bit;
reference(); // intentionally not implemented
reference(); // intentionally not implemented
reference(dynamic_bitset& bs_, size_type bit_) : bs(&bs_), bit(bit_){ }
public:
reference& operator=(bool value) // for b[i] = x
@@ -97,30 +95,30 @@ public:
bs->set(bit);
else
bs->reset(bit);
return *this;
return *this;
}
reference& operator|=(bool value) // for b[i] |= x
{
if (value)
bs->set(bit);
return *this;
return *this;
}
reference& operator&=(bool value) // for b[i] &= x
{
if (! (value && bs->test(bit)))
bs->reset(bit);
return *this;
return *this;
}
reference& operator^=(bool value) // for b[i] ^= x
{
bs->set(bit, bs->test(bit) ^ value);
return *this;
return *this;
}
reference& operator-=(bool value) // for b[i] -= x
{
if (!value)
bs->reset(bit);
return *this;
return *this;
}
reference& operator=(const reference& j) // for b[i] = b[j]
{
@@ -128,34 +126,34 @@ public:
bs->set(bit);
else
bs->reset(bit);
return *this;
return *this;
}
reference& operator|=(const reference& j) // for b[i] |= b[j]
{
if (j.bs->test(j.bit))
bs->set(bit);
return *this;
return *this;
}
reference& operator&=(const reference& j) // for b[i] &= b[j]
{
if (! (j.bs->test(j.bit) && bs->test(bit)))
bs->reset(bit);
return *this;
return *this;
}
reference& operator^=(const reference& j) // for b[i] ^= b[j]
{
bs->set(bit, bs->test(bit) ^ j.bs->test(j.bit));
return *this;
return *this;
}
reference& operator-=(const reference& j) // for b[i] -= b[j]
{
if (!j.bs->test(j.bit))
bs->reset(bit);
return *this;
return *this;
}
bool operator~() const // flips the bit
{
return ! bs->test(bit);
return ! bs->test(bit);
}
operator bool() const // for x = b[i]
{
@@ -164,7 +162,7 @@ public:
reference& flip() // for b[i].flip();
{
bs->flip(bit);
return *this;
return *this;
}
};
typedef bool const_reference;
@@ -181,7 +179,7 @@ public:
#if defined(BOOST_OLD_IOSTREAMS)
explicit
dynamic_bitset(const std::string& s,
std::string::size_type pos = 0,
std::string::size_type pos = 0,
std::string::size_type n = std::string::npos,
const Allocator& alloc = Allocator())
: detail::dynamic_bitset_base<Block, Allocator>
@@ -191,9 +189,9 @@ public:
// in the code below are to avoid a g++ 3.2 bug and a Borland bug. -JGS
template <typename CharT, typename Traits, typename Alloc>
explicit
dynamic_bitset(const std::basic_string<CharT, Traits, Alloc>& s,
typename std::basic_string<CharT, Traits, Alloc>::size_type pos = 0,
typename std::basic_string<CharT, Traits, Alloc>::size_type n
dynamic_bitset(const std::basic_string<CharT, Traits, Alloc>& s,
typename std::basic_string<CharT, Traits, Alloc>::size_type pos = 0,
typename std::basic_string<CharT, Traits, Alloc>::size_type n
= (std::basic_string<CharT, Traits, Alloc>::npos),
const Allocator& alloc = Allocator())
: detail::dynamic_bitset_base<Block, Allocator>
@@ -202,7 +200,7 @@ public:
{
// Locate sub string
assert(pos <= s.length());
from_string(s, pos, std::min(n, s.size() - pos));
from_string(s, pos, std::min(n, s.size() - pos));
}
// The first bit in *first is the least significant bit, and the
@@ -211,8 +209,8 @@ public:
dynamic_bitset(BlockInputIterator first, BlockInputIterator last,
const Allocator& alloc = Allocator())
: detail::dynamic_bitset_base<Block, Allocator>
(detail::initial_num_blocks(first, last)
* bits_per_block, alloc)
(detail::initial_num_blocks(first, last)
* bits_per_block, alloc)
{
if (first != last) {
if (this->m_num_bits == 0) { // dealing with input iterators
@@ -222,7 +220,7 @@ public:
for (std::size_t i = 0; first != last; ++first, ++i)
set_block_(i, *first);
}
}
}
}
@@ -261,7 +259,7 @@ public:
append(*first);
}
}
}
}
}
@@ -293,7 +291,7 @@ public:
bool operator[](size_type pos) const { return test_(pos); } //[gps]
unsigned long to_ulong() const;
size_type size() const;
size_type num_blocks() const;
@@ -304,17 +302,17 @@ public:
#ifdef BOOST_DYN_BITSET_USE_FRIENDS
// lexicographical comparison
template <typename B, typename A>
friend bool operator==(const dynamic_bitset<B, A>& a,
friend bool operator==(const dynamic_bitset<B, A>& a,
const dynamic_bitset<B, A>& b);
template <typename B, typename A>
friend bool operator<(const dynamic_bitset<B, A>& a,
friend bool operator<(const dynamic_bitset<B, A>& a,
const dynamic_bitset<B, A>& b);
template <typename B, typename A>
friend bool operator>(const dynamic_bitset<B, A>& a,
friend bool operator>(const dynamic_bitset<B, A>& a,
const dynamic_bitset<B, A>& b);
template <typename B, typename A, typename BlockOutputIterator>
friend void to_block_range(const dynamic_bitset<B, A>& b,
friend void to_block_range(const dynamic_bitset<B, A>& b,
BlockOutputIterator result);
template <typename BlockIterator, typename B, typename A>
@@ -322,7 +320,7 @@ public:
dynamic_bitset<B, A>& result);
template <typename B, typename A, typename CharT, typename Alloc>
friend void dump_to_string(const dynamic_bitset<B, A>& b,
friend void dump_to_string(const dynamic_bitset<B, A>& b,
std::basic_string<CharT, Alloc>& s);
#endif
@@ -347,12 +345,12 @@ public:
// Assumes string contains only 0's and 1's
for (size_type i = 0; i < tot; ++i) {
if (s[pos + tot - i - 1] == '1') {
if (s[pos + tot - i - 1] == '1') {
set_(i);
} else {
assert(s[pos + tot - i - 1] == '0');
assert(s[pos + tot - i - 1] == '0');
}
}
}
}
};
@@ -361,25 +359,25 @@ public:
// comparison
template <typename Block, typename Allocator>
bool operator!=(const dynamic_bitset<Block, Allocator>& a,
bool operator!=(const dynamic_bitset<Block, Allocator>& a,
const dynamic_bitset<Block, Allocator>& b);
template <typename Block, typename Allocator>
bool operator<=(const dynamic_bitset<Block, Allocator>& a,
bool operator<=(const dynamic_bitset<Block, Allocator>& a,
const dynamic_bitset<Block, Allocator>& b);
template <typename Block, typename Allocator>
bool operator>(const dynamic_bitset<Block, Allocator>& a,
bool operator>(const dynamic_bitset<Block, Allocator>& a,
const dynamic_bitset<Block, Allocator>& b);
template <typename Block, typename Allocator>
bool operator>=(const dynamic_bitset<Block, Allocator>& a,
bool operator>=(const dynamic_bitset<Block, Allocator>& a,
const dynamic_bitset<Block, Allocator>& b);
// stream operators
#ifdef BOOST_OLD_IOSTREAMS
template <typename Block, typename Allocator>
std::ostream& operator<<(std::ostream& os,
std::ostream& operator<<(std::ostream& os,
const dynamic_bitset<Block, Allocator>& b);
template <typename Block, typename Allocator>
@@ -387,24 +385,24 @@ std::istream& operator>>(std::istream& is, dynamic_bitset<Block,Allocator>& b);
#else
template <typename CharT, typename Traits, typename Block, typename Allocator>
std::basic_ostream<CharT, Traits>&
operator<<(std::basic_ostream<CharT, Traits>& os,
operator<<(std::basic_ostream<CharT, Traits>& os,
const dynamic_bitset<Block, Allocator>& b);
template <typename CharT, typename Traits, typename Block, typename Allocator>
std::basic_istream<CharT, Traits>&
operator>>(std::basic_istream<CharT, Traits>& is,
operator>>(std::basic_istream<CharT, Traits>& is,
dynamic_bitset<Block, Allocator>& b);
#endif
// bitset operations
template <typename Block, typename Allocator>
dynamic_bitset<Block, Allocator>
operator&(const dynamic_bitset<Block, Allocator>& b1,
operator&(const dynamic_bitset<Block, Allocator>& b1,
const dynamic_bitset<Block, Allocator>& b2);
template <typename Block, typename Allocator>
dynamic_bitset<Block, Allocator>
operator|(const dynamic_bitset<Block, Allocator>& b1,
operator|(const dynamic_bitset<Block, Allocator>& b1,
const dynamic_bitset<Block, Allocator>& b2);
template <typename Block, typename Allocator>
@@ -419,13 +417,13 @@ operator-(const dynamic_bitset<Block, Allocator>& b1,
template <typename Block, typename Allocator, typename CharT, typename Alloc>
void
to_string(const dynamic_bitset<Block, Allocator>& b,
void
to_string(const dynamic_bitset<Block, Allocator>& b,
std::basic_string<CharT, Alloc>& s);
template <typename Block, typename Allocator, typename BlockOutputIterator>
void
to_block_range(const dynamic_bitset<Block, Allocator>& b,
to_block_range(const dynamic_bitset<Block, Allocator>& b,
BlockOutputIterator result);
template <typename BlockIterator, typename B, typename A>
@@ -439,7 +437,7 @@ from_block_range(BlockIterator first, BlockIterator last,
#ifdef BOOST_OLD_IOSTREAMS
template <typename Block, typename Allocator>
inline std::ostream&
operator<<(std::ostream& os,
operator<<(std::ostream& os,
const typename dynamic_bitset<Block, Allocator>::reference& br)
{
return os << (bool)br;
@@ -447,7 +445,7 @@ operator<<(std::ostream& os,
#else
template <typename CharT, typename Traits, typename Block, typename Allocator>
inline std::basic_ostream<CharT, Traits>&
operator<<(std::basic_ostream<CharT, Traits>& os,
operator<<(std::basic_ostream<CharT, Traits>& os,
const typename dynamic_bitset<Block, Allocator>::reference& br)
{
return os << (bool)br;
@@ -647,9 +645,9 @@ dynamic_bitset<Block, Allocator>::operator<<=(size_type n)
size_type const last = this->m_num_blocks - 1; // m_num_blocks is >= 1
size_type const div = n / bits_per_block; // div is <= last
size_type const r = n % bits_per_block;
// PRE: div != 0 or r != 0
if (r != 0) {
block_type const rs = bits_per_block - r;
@@ -658,7 +656,7 @@ dynamic_bitset<Block, Allocator>::operator<<=(size_type n)
this->m_bits[i+div] = (this->m_bits[i] << r) | (this->m_bits[i-1] >> rs);
}
this->m_bits[div] = this->m_bits[0] << r;
}
else {
for (size_type i = last-div; i>0; --i) {
@@ -666,12 +664,12 @@ dynamic_bitset<Block, Allocator>::operator<<=(size_type n)
}
this->m_bits[div] = this->m_bits[0];
}
// div blocks are zero filled at the less significant end
std::fill(this->m_bits, this->m_bits+div, static_cast<block_type>(0));
}
return *this;
@@ -694,7 +692,7 @@ dynamic_bitset<Block, Allocator>::operator>>=(size_type n)
size_type i;
for (i = 0; i < this->m_num_bits - n; ++i)
set_(i,test_(i+n));
for (i = this->m_num_bits - n; i < this->m_num_bits; ++i)
reset_(i);
}
@@ -707,7 +705,7 @@ dynamic_bitset<Block, Allocator>::operator>>=(size_type n)
// NOTE: this assumes that within a single block bits are
// numbered from right to left. G.P.S.
//
// static Block offset(size_type bit)
// static Block offset(size_type bit)
// { return bit % bits_per_block; }
//
//
@@ -728,7 +726,7 @@ dynamic_bitset<B, A> & dynamic_bitset<B, A>::operator>>=(size_type n) {
size_type const last = this->m_num_blocks - 1; // m_num_blocks is >= 1
size_type const div = n / bits_per_block; // div is <= last
size_type const r = n % bits_per_block;
// PRE: div != 0 or r != 0
if (r != 0) {
@@ -750,8 +748,8 @@ dynamic_bitset<B, A> & dynamic_bitset<B, A>::operator>>=(size_type n) {
// this->m_bits[last-div] = this->m_bits[last] >> 0;
}
// div blocks are zero filled at the most significant end
std::fill(this->m_bits+(this->m_num_blocks-div), this->m_bits+this->m_num_blocks, static_cast<block_type>(0));
}
@@ -894,7 +892,7 @@ dynamic_bitset<Block, Allocator>::count() const
}
The actual algorithm used is based on using a lookup
table.
table.
The basic idea of the method is to pick up X bits at a time
@@ -902,7 +900,7 @@ table.
the binary representation of a number N. Then, to use a table
of 1<<X elements where table[N] is the number of '1' digits
in the binary representation of N (i.e. in our X bits).
Note that the table can be oversized (i.e. can even have more
than 1<<X elements; in that case only the first 1<<X will be
actually used) but it cannot be undersized.
@@ -951,7 +949,7 @@ dynamic_bitset<Block, Allocator>::count() const
do {
num += detail::count<>::table[value & ((1<<max_bit)-1)];
} while (value >>= max_bit);
++p;
}
}
@@ -966,8 +964,8 @@ dynamic_bitset<Block, Allocator>::count() const
// take as ref param instead?
template <typename Block, typename Allocator, typename CharT, typename Alloc>
void
to_string(const dynamic_bitset<Block, Allocator>& b,
void
to_string(const dynamic_bitset<Block, Allocator>& b,
std::basic_string<CharT, Alloc>& s)
{
s.assign(b.size(), '0');
@@ -982,8 +980,8 @@ to_string(const dynamic_bitset<Block, Allocator>& b,
// for debugging purposes)
//
template <typename B, typename A, typename CharT, typename Alloc>
void
dump_to_string(const dynamic_bitset<B, A>& b,
void
dump_to_string(const dynamic_bitset<B, A>& b,
std::basic_string<CharT, Alloc>& s)
{
std::size_t const len = b.m_num_blocks * (dynamic_bitset<B, A>::bits_per_block);
@@ -995,11 +993,11 @@ dump_to_string(const dynamic_bitset<B, A>& b,
template <typename Block, typename Allocator, typename BlockOutputIterator>
void
to_block_range(const dynamic_bitset<Block, Allocator>& b,
to_block_range(const dynamic_bitset<Block, Allocator>& b,
BlockOutputIterator result)
{
assert(b.size() != 0 || b.num_blocks() == 0);
std::copy (b.m_bits, b.m_bits + b.m_num_blocks, result);
std::copy (b.m_bits, b.m_bits + b.m_num_blocks, result);
}
template <typename BlockIterator, typename B, typename A>
@@ -1013,14 +1011,14 @@ from_block_range(BlockIterator first, BlockIterator last,
template <typename Block, typename Allocator>
unsigned long dynamic_bitset<Block, Allocator>::
to_ulong() const
to_ulong() const
{
const std::overflow_error
overflow("boost::bit_set::operator unsigned long()");
if (this->m_num_blocks == 0)
return 0;
if (sizeof(Block) >= sizeof(unsigned long)) {
for (size_type i = 1; i < this->m_num_blocks; ++i)
if (this->m_bits[i])
@@ -1104,7 +1102,7 @@ is_proper_subset_of(const dynamic_bitset<Block, Allocator>& a) const
// comparison
template <typename Block, typename Allocator>
bool operator==(const dynamic_bitset<Block, Allocator>& a,
bool operator==(const dynamic_bitset<Block, Allocator>& a,
const dynamic_bitset<Block, Allocator>& b)
{
using namespace std;
@@ -1114,7 +1112,7 @@ bool operator==(const dynamic_bitset<Block, Allocator>& a,
}
template <typename Block, typename Allocator>
inline bool operator!=(const dynamic_bitset<Block, Allocator>& a,
inline bool operator!=(const dynamic_bitset<Block, Allocator>& a,
const dynamic_bitset<Block, Allocator>& b)
{
return !(a == b);
@@ -1147,14 +1145,14 @@ bool operator<(const dynamic_bitset<Block, Allocator>& a,
}
template <typename Block, typename Allocator>
inline bool operator<=(const dynamic_bitset<Block, Allocator>& a,
inline bool operator<=(const dynamic_bitset<Block, Allocator>& a,
const dynamic_bitset<Block, Allocator>& b)
{
return !(a > b);
}
template <typename Block, typename Allocator>
inline bool operator>(const dynamic_bitset<Block, Allocator>& a,
inline bool operator>(const dynamic_bitset<Block, Allocator>& a,
const dynamic_bitset<Block, Allocator>& b)
{
assert(a.size() == b.size());
@@ -1180,7 +1178,7 @@ inline bool operator>(const dynamic_bitset<Block, Allocator>& a,
}
template <typename Block, typename Allocator>
inline bool operator>=(const dynamic_bitset<Block, Allocator>& a,
inline bool operator>=(const dynamic_bitset<Block, Allocator>& a,
const dynamic_bitset<Block, Allocator>& b)
{
return !(a < b);
@@ -1284,7 +1282,7 @@ operator>>(std::basic_istream<CharT, Traits>& in_stream,
} else {
char c2 = Traits::to_char_type(c1);
char c = in_stream.narrow(c2, '*');
if (c == '0' || c == '1')
tmp += c; // old dinkumware basic_string missing push_back
else if (Traits::eq_int_type(read_buf->sputbackc(c2), Traits::eof()))
@@ -1294,7 +1292,7 @@ operator>>(std::basic_istream<CharT, Traits>& in_stream,
}
}
} // for
if (tmp.empty()) // did not read in enough bits
in_stream.setstate(std::ios_base::failbit);
else

View File

@@ -1,13 +1,3 @@
// (C) Copyright Chuck Allison and Jeremy Siek 2001, 2002.
//
// Permission to copy, use, modify, sell and distribute this software
// is granted provided this copyright notice appears in all
// copies. This software is provided "as is" without express or
// implied warranty, and with no claim as to its suitability for any
// purpose.
// See http://www.boost.org/libs/dynamic_bitset for documentation.
#ifndef BOOST_DYNAMIC_BITSET_FWD_HPP
#define BOOST_DYNAMIC_BITSET_FWD_HPP