boost::dynamic_bitset

The dynamic_bitset template represents a set of bits.

Synopsis

Declared in <boost/dynamic_bitset/dynamic_bitset.hpp>

template<
    typename Block = unsigned long,
    typename AllocatorOrContainer = std::allocator<Block>>
class dynamic_bitset;

Types

Name

Description

reference

A proxy class to simulate lvalues of bit type.

serialize_impl

Optional zero‐copy serialization support.

allocator_type

The allocator used for all memory allocations.

block_type

The same type as Block.

const_iterator

A read‐only iterator into the bitset.

const_reference

The type bool.

const_reverse_iterator

A reverse read‐only iterator into the bitset.

iterator

A read/write iterator into the bitset.

reverse_iterator

A reverse read/write reverse iterator into the bitset.

size_type

An unsigned integral type that can represent the size of the bitset. See size().

Member Functions

Name

Description

dynamic_bitset [constructor]

Constructors

~dynamic_bitset [destructor]

Destructor.

operator=

Assignment operators

all

Checks whether all bits in *this are set.

any

Checks whether any bits in *this are set.

append

append overloads

at

A checked version of operator[]().

begin

begin overloads

capacity

Returns the total number of elements that *this can hold without requiring reallocation.

cbegin

Returns a read‐only iterator that refers to the least significant bit in the bitset.

cend

Returns a read‐only iterator that refers to one past the most significant bit in the bitset.

clear

Clears the bitset, i.e. makes its size zero.

count

Returns the number of bits in this bitset that are set.

crbegin

Returns a read‐only reverse iterator that refers to the most significant bit in the bitset.

crend

Returns a read‐only reverse iterator that refers to one before the least significant bit in the bitset.

empty

Checks whether this bitset has size zero.

end

end overloads

find_first

Finds the first set bit in *this with an index >= pos, if any.

find_first_off

Finds the first unset bit in *this with an index >= pos, if any.

find_next

Finds the first bit set in *this with an index > pos, if any.

find_next_off

Finds the first unset bit in *this with an index > pos, if any.

flip

flip overloads

get_allocator

Returns a copy of the allocator object used to construct *this.

intersects

Checks whether *this intersects with b.

is_proper_subset_of

Checks whether *this is a proper subset of b.

is_subset_of

Checks whether *this is a subset of b.

max_size

Returns the maximum size of a bitset of this type.

none

Checks whether this bitset has no set bit.

num_blocks

Returns the number of blocks in this bitset.

operator&=

Bitwise‐ANDs all the bits in this bitset with the bits in b.

operator‐=

Computes the set difference of this bitset and the b bitset.

operator<<=

Shifts the bits in this bitset to the left by n positions.

operator>>

Returns a shifted copy of *this.

operator>>=

Shifts the bits in this bitset to the right by n positions.

operator[]

Subscript operators

operatorˆ=

Bitwise‐XORs all the bits in this bitset with the bits in b.

operator|=

Bitwise‐ORs all the bits in this bitset with the bits in b.

operator~

Returns a copy of *this with all of its bits toggled.

pop_back

Decreases the size of the bitset by one, removing the most significant bit.

pop_front

Decreases the size of the bitset by one, removing the least significant bit.

push_back

Increases the size of the bitset by one, and sets the value of the new most significant bit to bit.

push_front

Increases the size of the bitset by one, and sets the value of the new least significant bit to bit.

rbegin

rbegin overloads

rend

rend overloads

reserve

Informs the bitset of a planned change in size, so that it can manage the storage allocation accordingly.

reset

reset overloads

resize

Changes the number of bits of the bitset to num_bits.

set

set overloads

shrink_to_fit

Requests the bitset to reduce memory use by removing unused capacity.

size

Returns the number of bits in this bitset.

swap

Swaps the contents of this bitset and bitset b.

test

Tests the bit at the given position.

test_set

Sets bit pos if val is true, and clears it if val is false.

to_ulong

Returns the numeric value corresponding to the bits in *this.

operator<<

Returns a shifted copy of *this.

Static Data Members

Name

Description

bits_per_block

The number of bits the type Block uses to represent values, excluding any padding bits. Numerically equal to std::numeric_limits< Block >::digits.

npos

The maximum value of size_type.

Friends

Name Description

boost::dynamic_bitset::bit_appender

boost::dynamic_bitset::serialize_impl

Optional zero‐copy serialization support.

boost::hash_value

Computes a hash value for a dynamic_bitset.

boost::to_string_helper

boost::operator>>

boost::from_block_range

boost::to_block_range

boost::operator<

Less‐than operator

boost::operator==

Equality operator

boost::const_bit_iterator

boost::bit_iterator

Non-Member Functions

Name

Description

operator!=

Compares two bitsets.

operator&

Performs a bitwise‐AND of two bitsets.

operator‐

Calculates the set difference of two bitsets.

operator<

Compares two bitsets.

operator<=

Compares two bitsets.

operator==

Compares two bitsets.

operator>

Compares two bitsets.

operator>=

Compares two bitsets.

operatorˆ

Performs a bitwise‐XOR of two bitsets.

operator|

Performs a bitwise‐OR of two bitsets.

swap

Exchanges the contents of a and b.

to_block_range

Writes the bits of the bitset into the iterator result, a block at a time.

to_string

Copies a representation of b into the string s.

Template parameters

Block The integer type in which the bits are stored. Defaults to unsigned long.

AllocatorOrContainer Either an allocator (to use for all internal memory management) or a container of Block's. Defaults to std::allocator< Block >.

Concepts modeled

DefaultConstructible, CopyConstructible, CopyAssignable, MoveConstructible, MoveAssignable, EqualityComparable, LessThanComparable.

Type requirements

Block is a cv‐unqualified unsigned integer type other than bool. AllocatorOrContainer satisfies the standard requirements for an allocator or is a container‐like type which provides at least bidirectional iterators.

Created with MrDocs