std::tr2::dynamic_bitset< _WordT, _Alloc > Class Template Reference
Extensions » Dynamic Bitset.

`#include <dynamic_bitset>`

Inheritance diagram for std::tr2::dynamic_bitset< _WordT, _Alloc >:
[legend]

## Classes

class | reference

## Public Types

typedef __dynamic_bitset_base< _WordT, _Alloc > | _Base
typedef _Alloc | allocator_type
typedef _WordT | block_type
typedef bool | const_reference
typedef size_t | size_type

## Public Member Functions

| dynamic_bitset ()=default
| dynamic_bitset (const allocator_type &__alloc)
| dynamic_bitset (const char *__str, const allocator_type &__alloc=allocator_type())
| dynamic_bitset (const dynamic_bitset &)=default
template<typename _CharT, typename _Traits, typename _Alloc1>
| dynamic_bitset (const std::basic_string< _CharT, _Traits, _Alloc1 > &__str, typename basic_string< _CharT, _Traits, _Alloc1 >::size_type __pos=0, typename basic_string< _CharT, _Traits, _Alloc1 >::size_type __n=std::basic_string< _CharT, _Traits, _Alloc1 >::npos, _CharT __zero=_CharT('0'), _CharT __one=_CharT('1'), const allocator_type &__alloc=allocator_type())
| dynamic_bitset (dynamic_bitset &&__b) noexcept
| dynamic_bitset (initializer_list< block_type > __il, const allocator_type &__alloc=allocator_type())
| dynamic_bitset (size_type __nbits, unsigned long long __val=0ULL, const allocator_type &__alloc=allocator_type())
template<typename _Traits = std::char_traits<char>, typename _CharT = typename _Traits::char_type>
void | _M_copy_from_ptr (const _CharT *, size_t, size_t, size_t, _CharT __zero=_CharT('0'), _CharT __one=_CharT('1'))
template<typename _CharT, typename _Traits, typename _Alloc1>
void | _M_copy_from_string (const basic_string< _CharT, _Traits, _Alloc1 > &__str, size_t __pos, size_t __n, _CharT __zero=_CharT('0'), _CharT __one=_CharT('1'))
template<typename _CharT, typename _Traits, typename _Alloc1>
void | _M_copy_to_string (std::basic_string< _CharT, _Traits, _Alloc1 > &__str, _CharT __zero=_CharT('0'), _CharT __one=_CharT('1')) const
bool | all () const
bool | any () const
template<typename _BlockInputIterator>
void | append (_BlockInputIterator __first, _BlockInputIterator __last)
void | append (block_type __block)
void | append (initializer_list< block_type > __il)
void | clear ()
size_type | count () const noexcept
bool | empty () const noexcept
size_type | find_first () const
size_type | find_next (size_t __prev) const
dynamic_bitset & | flip ()
dynamic_bitset & | flip (size_type __pos)
allocator_type | get_allocator () const noexcept
bool | is_proper_subset_of (const dynamic_bitset &__b) const
bool | is_subset_of (const dynamic_bitset &__b) const
constexpr size_type | max_size () noexcept
bool | none () const
size_type | num_blocks () const noexcept
dynamic_bitset & | operator= (const dynamic_bitset &)=default
dynamic_bitset & | operator= (dynamic_bitset &&__b) noexcept(std::is_nothrow_move_assignable< _Base >::value)
dynamic_bitset | operator~ () const
void | push_back (bool __bit)
dynamic_bitset & | reset ()
dynamic_bitset & | reset (size_type __pos)
void | resize (size_type __nbits, bool __value=false)
dynamic_bitset & | set ()
dynamic_bitset & | set (size_type __pos, bool __val=true)
size_type | size () const noexcept
void | swap (dynamic_bitset &__b) noexcept
bool | test (size_type __pos) const
template<typename _CharT = char, typename _Traits = std::char_traits<_CharT>, typename _Alloc1 = std::allocator<_CharT>>
std::basic_string< _CharT, _Traits, _Alloc1 > | to_string (_CharT __zero=_CharT('0'), _CharT __one=_CharT('1')) const
unsigned long long | to_ullong () const
unsigned long | to_ulong () const
dynamic_bitset & | operator&= (const dynamic_bitset &__rhs)
dynamic_bitset & | operator&= (dynamic_bitset &&__rhs)
dynamic_bitset & | operator|= (const dynamic_bitset &__rhs)
dynamic_bitset & | operator^= (const dynamic_bitset &__rhs)
dynamic_bitset & | operator-= (const dynamic_bitset &__rhs)
dynamic_bitset & | operator<<= (size_type __pos)
dynamic_bitset & | operator>>= (size_type __pos)
reference | operator[] (size_type __pos)
const_reference | operator[] (size_type __pos) const
dynamic_bitset | operator<< (size_type __pos) const
dynamic_bitset | operator>> (size_type __pos) const

## Static Public Attributes

static const size_type | bits_per_block
static const size_type | npos

## Friends

bool | operator< (const dynamic_bitset &__lhs, const dynamic_bitset &__rhs) noexcept
bool | operator== (const dynamic_bitset &__lhs, const dynamic_bitset &__rhs) noexcept
class | reference

## Detailed Description

template<typename _WordT = unsigned long long, typename _Alloc = std::allocator<_WordT>>
class std::tr2::dynamic_bitset< _WordT, _Alloc >

The dynamic_bitset class represents a sequence of bits.

See N2050, Proposal to Add a Dynamically Sizeable Bitset to the Standard Library. http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2006/n2050.pdf

In the general unoptimized case, storage is allocated in word-sized blocks. Let B be the number of bits in a word, then (Nb+(B-1))/B words will be used for storage. B - NbB bits are unused. (They are the high-order bits in the highest word.) It is a class invariant that those unused bits are always zero.

If you think of dynamic_bitset as "a simple array of bits," be aware that your mental picture is reversed: a dynamic_bitset behaves the same way as bits in integers do, with the bit at index 0 in the "least significant / right-hand" position, and the bit at index Nb-1 in the "most significant / left-hand" position. Thus, unlike other containers, a dynamic_bitset's index "counts from right to left," to put it very loosely.

This behavior is preserved when translating to and from strings. For example, the first line of the following program probably prints "b('a') is 0001100001" on a modern ASCII system.

#include <dynamic_bitset>
#include <iostream>
#include <sstream>
using namespace std;
int main()
{
long a = 'a';
dynamic_bitset<> b(a);
cout << "b('a') is " << b << endl;
ostringstream s;
s << b;
string str = s.str();
cout << "index 3 in the string is " << str[3] << " but\n"
<< "index 3 in the bitset is " << b[3] << endl;
}
iostream
sstream
dynamic_bitset
std::ostringstream
basic_ostringstream< char > ostringstream
Class for char output memory streams.
Definition iosfwd:157
std
ISO C++ entities toplevel namespace is std.
std::endl
basic_ostream< _CharT, _Traits > & endl(basic_ostream< _CharT, _Traits > &__os)
Write a newline and flush the stream.
Definition ostream:66
std::cout
ostream cout
Linked to standard output.
std::basic_ostringstream::str
__string_type str() const &
Copying out the string buffer.
Definition sstream:941
std::tr2::dynamic_bitset::dynamic_bitset
dynamic_bitset()=default
All bits set to zero.

Most of the actual code isn't contained in dynamic_bitset<> itself, but in the base class __dynamic_bitset_base. The base class works with whole words, not with individual bits. This allows us to specialize __dynamic_bitset_base for the important special case where the dynamic_bitset is only a single word.

Extra confusion can result due to the fact that the storage for __dynamic_bitset_base is a vector, and is indexed as such. This is carefully encapsulated.

Definition at line 421 of file dynamic_bitset.

## Member Typedef Documentation

## _Base

template<typename _WordT = unsigned long long, typename _Alloc = std::allocator<_WordT>>

typedef __dynamic_bitset_base<_WordT, _Alloc> std::tr2::dynamic_bitset< _WordT, _Alloc >::_Base

Definition at line 429 of file dynamic_bitset.

## allocator_type

template<typename _WordT = unsigned long long, typename _Alloc = std::allocator<_WordT>>

typedef _Alloc std::tr2::dynamic_bitset< _WordT, _Alloc >::allocator_type

Definition at line 431 of file dynamic_bitset.

## block_type

template<typename _WordT = unsigned long long, typename _Alloc = std::allocator<_WordT>>

typedef _WordT std::tr2::dynamic_bitset< _WordT, _Alloc >::block_type

Definition at line 430 of file dynamic_bitset.

## const_reference

template<typename _WordT = unsigned long long, typename _Alloc = std::allocator<_WordT>>

typedef bool std::tr2::dynamic_bitset< _WordT, _Alloc >::const_reference

Definition at line 571 of file dynamic_bitset.

## size_type

template<typename _WordT = unsigned long long, typename _Alloc = std::allocator<_WordT>>

typedef size_t std::tr2::dynamic_bitset< _WordT, _Alloc >::size_type

Definition at line 432 of file dynamic_bitset.

## Constructor & Destructor Documentation

## dynamic_bitset() [1/8]

template<typename _WordT = unsigned long long, typename _Alloc = std::allocator<_WordT>>

std::tr2::dynamic_bitset< _WordT, _Alloc >::dynamic_bitset | ( |  | ) |

default

All bits set to zero.

Referenced by dynamic_bitset(), dynamic_bitset(), operator&=(), operator&=(), operator-=(), operator<<(), operator<<=(), operator=(), operator=(), operator>>(), operator^=(), operator|=(), operator~(), and swap().

## dynamic_bitset() [2/8]

template<typename _WordT = unsigned long long, typename _Alloc = std::allocator<_WordT>>

std::tr2::dynamic_bitset< _WordT, _Alloc >::dynamic_bitset | ( | const allocator_type & | __alloc | ) |

inline explicit

All bits set to zero.

Definition at line 580 of file dynamic_bitset.

## dynamic_bitset() [3/8]

template<typename _WordT = unsigned long long, typename _Alloc = std::allocator<_WordT>>

std::tr2::dynamic_bitset< _WordT, _Alloc >::dynamic_bitset | ( | size_type | __nbits,
|  | unsigned long long | __val = 0ULL,
|  | const allocator_type & | __alloc = allocator_type() )

inline explicit

Initial bits bitwise-copied from a single word (others set to zero).

Definition at line 586 of file dynamic_bitset.

## dynamic_bitset() [4/8]

template<typename _WordT = unsigned long long, typename _Alloc = std::allocator<_WordT>>

std::tr2::dynamic_bitset< _WordT, _Alloc >::dynamic_bitset | ( | initializer_list< block_type > | __il,
|  | const allocator_type & | __alloc = allocator_type() )

inline

Definition at line 592 of file dynamic_bitset.

## dynamic_bitset() [5/8]

template<typename _WordT = unsigned long long, typename _Alloc = std::allocator<_WordT>>
template<typename _CharT, typename _Traits, typename _Alloc1>

std::tr2::dynamic_bitset< _WordT, _Alloc >::dynamic_bitset | ( | const std::basic_string< _CharT, _Traits, _Alloc1 > & | __str,
|  | typename basic_string< _CharT, _Traits, _Alloc1 >::size_type | __pos = 0,
|  | typename basic_string< _CharT, _Traits, _Alloc1 >::size_type | __n = std::basic_string<_CharT, _Traits, _Alloc1>::npos,
|  | _CharT | __zero = _CharT('0'),
|  | _CharT | __one = _CharT('1'),
|  | const allocator_type & | __alloc = allocator_type() )

inline explicit

Use a subset of a string.

Parameters

  __str | A string of '0' and '1' characters.
  __pos | Index of the first character in `__str` to use.
  __n | The number of characters to copy.
  __zero | The character to use for unset bits.
  __one | The character to use for set bits.
  __alloc | An allocator.

Exceptions

  std::out_of_range | If `__pos` is bigger the size of `__str`.
  std::invalid_argument | If a character appears in the string which is neither '0' nor '1'.

Definition at line 611 of file dynamic_bitset.

References std::basic_string< _CharT, _Traits, _Alloc >::npos, and std::basic_string< _CharT, _Traits, _Alloc >::size().

## dynamic_bitset() [6/8]

template<typename _WordT = unsigned long long, typename _Alloc = std::allocator<_WordT>>

std::tr2::dynamic_bitset< _WordT, _Alloc >::dynamic_bitset | ( | const char * | __str,
|  | const allocator_type & | __alloc = allocator_type() )

inline explicit

Construct from a string.

Parameters

  __str | A string of '0' and '1' characters.
  __alloc | An allocator.

Exceptions

  std::invalid_argument | If a character appears in the string which is neither '0' nor '1'.

Definition at line 638 of file dynamic_bitset.

## dynamic_bitset() [7/8]

template<typename _WordT = unsigned long long, typename _Alloc = std::allocator<_WordT>>

std::tr2::dynamic_bitset< _WordT, _Alloc >::dynamic_bitset | ( | const dynamic_bitset< _WordT, _Alloc > & |  | ) |

default

Copy constructor.

References dynamic_bitset().

## dynamic_bitset() [8/8]

template<typename _WordT = unsigned long long, typename _Alloc = std::allocator<_WordT>>

std::tr2::dynamic_bitset< _WordT, _Alloc >::dynamic_bitset | ( | dynamic_bitset< _WordT, _Alloc > && | __b | ) |

inline noexcept

Move constructor.

Definition at line 650 of file dynamic_bitset.

References dynamic_bitset(), and std::move().

## Member Function Documentation

## _M_copy_from_ptr()

template<typename _WordT, typename _Alloc>
template<typename _Traits, typename _CharT>

void std::tr2::dynamic_bitset< _WordT, _Alloc >::_M_copy_from_ptr | ( | const _CharT * | __str,
|  | size_t | __len,
|  | size_t | __pos,
|  | size_t | __n,
|  | _CharT | __zero = _CharT('0'),
|  | _CharT | __one = _CharT('1') )

Definition at line 179 of file dynamic_bitset.tcc.

## _M_copy_from_string()

template<typename _WordT = unsigned long long, typename _Alloc = std::allocator<_WordT>>
template<typename _CharT, typename _Traits, typename _Alloc1>

void std::tr2::dynamic_bitset< _WordT, _Alloc >::_M_copy_from_string | ( | const basic_string< _CharT, _Traits, _Alloc1 > & | __str,
|  | size_t | __pos,
|  | size_t | __n,
|  | _CharT | __zero = _CharT('0'),
|  | _CharT | __one = _CharT('1') )

inline

Definition at line 974 of file dynamic_bitset.

## all()

template<typename _WordT = unsigned long long, typename _Alloc = std::allocator<_WordT>>

bool std::tr2::dynamic_bitset< _WordT, _Alloc >::all | ( |  | ) | const

inline

Tests whether all the bits are on.

Returns
  True if all the bits are set.

Definition at line 1035 of file dynamic_bitset.

## any()

template<typename _WordT = unsigned long long, typename _Alloc = std::allocator<_WordT>>

bool std::tr2::dynamic_bitset< _WordT, _Alloc >::any | ( |  | ) | const

inline

Tests whether any of the bits are on.

Returns
  True if at least one bit is set.

Definition at line 1043 of file dynamic_bitset.

## append() [1/3]

template<typename _WordT = unsigned long long, typename _Alloc = std::allocator<_WordT>>
template<typename _BlockInputIterator>

void std::tr2::dynamic_bitset< _WordT, _Alloc >::append | ( | _BlockInputIterator | __first,
|  | _BlockInputIterator | __last )

inline

Append an iterator range of blocks.

Definition at line 746 of file dynamic_bitset.

References append().

## append() [2/3]

template<typename _WordT = unsigned long long, typename _Alloc = std::allocator<_WordT>>

void std::tr2::dynamic_bitset< _WordT, _Alloc >::append | ( | block_type | __block | ) |

inline

Append a block.

Definition at line 728 of file dynamic_bitset.

Referenced by append().

## append() [3/3]

template<typename _WordT = unsigned long long, typename _Alloc = std::allocator<_WordT>>

void std::tr2::dynamic_bitset< _WordT, _Alloc >::append | ( | initializer_list< block_type > | __il | ) |

inline

Definition at line 738 of file dynamic_bitset.

## clear()

template<typename _WordT = unsigned long long, typename _Alloc = std::allocator<_WordT>>

void std::tr2::dynamic_bitset< _WordT, _Alloc >::clear | ( |  | ) |

inline

Clear the bitset.

Definition at line 703 of file dynamic_bitset.

## count()

template<typename _WordT = unsigned long long, typename _Alloc = std::allocator<_WordT>>

size_type std::tr2::dynamic_bitset< _WordT, _Alloc >::count | ( |  | ) | const

inline noexcept

Returns the number of bits which are set.

Definition at line 991 of file dynamic_bitset.

## empty()

template<typename _WordT = unsigned long long, typename _Alloc = std::allocator<_WordT>>

bool std::tr2::dynamic_bitset< _WordT, _Alloc >::empty | ( |  | ) | const

inline nodiscard noexcept

Returns true if the dynamic_bitset is empty.

Definition at line 1006 of file dynamic_bitset.

## find_first()

template<typename _WordT = unsigned long long, typename _Alloc = std::allocator<_WordT>>

size_type std::tr2::dynamic_bitset< _WordT, _Alloc >::find_first | ( |  | ) | const

inline

Finds the index of the first "on" bit.

Returns
  The index of the first bit set, or size() if not found.

See also
  find_next

Definition at line 1071 of file dynamic_bitset.

## find_next()

template<typename _WordT = unsigned long long, typename _Alloc = std::allocator<_WordT>>

size_type std::tr2::dynamic_bitset< _WordT, _Alloc >::find_next | ( | size_t | __prev | ) | const

inline

Finds the index of the next "on" bit after prev.

Returns
  The index of the next bit set, or size() if not found.

Parameters

  __prev | Where to start searching.

See also
  find_first

Definition at line 1081 of file dynamic_bitset.

## flip() [1/2]

template<typename _WordT = unsigned long long, typename _Alloc = std::allocator<_WordT>>

dynamic_bitset & std::tr2::dynamic_bitset< _WordT, _Alloc >::flip | ( |  | ) |

inline

Toggles every bit to its opposite value.

Definition at line 882 of file dynamic_bitset.

Referenced by operator~().

## flip() [2/2]

template<typename _WordT = unsigned long long, typename _Alloc = std::allocator<_WordT>>

dynamic_bitset & std::tr2::dynamic_bitset< _WordT, _Alloc >::flip | ( | size_type | __pos | ) |

inline

Toggles a given bit to its opposite value.

Parameters

  __pos | The index of the bit.

Exceptions

  std::out_of_range | If __pos is bigger the size of the set.

Definition at line 895 of file dynamic_bitset.

## get_allocator()

template<typename _WordT = unsigned long long, typename _Alloc = std::allocator<_WordT>>

allocator_type std::tr2::dynamic_bitset< _WordT, _Alloc >::get_allocator | ( |  | ) | const

inline noexcept

Return the allocator for the bitset.

Definition at line 683 of file dynamic_bitset.

Referenced by operator=().

## is_proper_subset_of()

template<typename _WordT = unsigned long long, typename _Alloc = std::allocator<_WordT>>

bool std::tr2::dynamic_bitset< _WordT, _Alloc >::is_proper_subset_of | ( | const dynamic_bitset< _WordT, _Alloc > & | __b | ) | const

inline

Definition at line 1089 of file dynamic_bitset.

## is_subset_of()

template<typename _WordT = unsigned long long, typename _Alloc = std::allocator<_WordT>>

bool std::tr2::dynamic_bitset< _WordT, _Alloc >::is_subset_of | ( | const dynamic_bitset< _WordT, _Alloc > & | __b | ) | const

inline

Definition at line 1085 of file dynamic_bitset.

## max_size()

template<typename _WordT = unsigned long long, typename _Alloc = std::allocator<_WordT>>

size_type std::tr2::dynamic_bitset< _WordT, _Alloc >::max_size | ( |  | ) |

inline constexpr noexcept

Returns the maximum size of a dynamic_bitset object having the same type as *this. The real answer is max() * bits_per_block but is likely to overflow.

Definition at line 1013 of file dynamic_bitset.

References std::numeric_limits< _Tp >::max().

## none()

template<typename _WordT = unsigned long long, typename _Alloc = std::allocator<_WordT>>

bool std::tr2::dynamic_bitset< _WordT, _Alloc >::none | ( |  | ) | const

inline

Tests whether any of the bits are on.

Returns
  True if none of the bits are set.

Definition at line 1051 of file dynamic_bitset.

## num_blocks()

template<typename _WordT = unsigned long long, typename _Alloc = std::allocator<_WordT>>

size_type std::tr2::dynamic_bitset< _WordT, _Alloc >::num_blocks | ( |  | ) | const

inline noexcept

Returns the total number of blocks.

Definition at line 1001 of file dynamic_bitset.

## operator&=() [1/2]

template<typename _WordT = unsigned long long, typename _Alloc = std::allocator<_WordT>>

dynamic_bitset & std::tr2::dynamic_bitset< _WordT, _Alloc >::operator&= | ( | const dynamic_bitset< _WordT, _Alloc > & | __rhs | ) |

inline

Operations on dynamic_bitsets.

Parameters

  __rhs | A same-sized dynamic_bitset.

These should be self-explanatory.

Definition at line 761 of file dynamic_bitset.

References dynamic_bitset().

## operator&=() [2/2]

template<typename _WordT = unsigned long long, typename _Alloc = std::allocator<_WordT>>

dynamic_bitset & std::tr2::dynamic_bitset< _WordT, _Alloc >::operator&= | ( | dynamic_bitset< _WordT, _Alloc > && | __rhs | ) |

inline

Operations on dynamic_bitsets.

Parameters

  __rhs | A same-sized dynamic_bitset.

These should be self-explanatory.

Definition at line 768 of file dynamic_bitset.

References dynamic_bitset(), and std::move().

## operator-=()

template<typename _WordT = unsigned long long, typename _Alloc = std::allocator<_WordT>>

dynamic_bitset & std::tr2::dynamic_bitset< _WordT, _Alloc >::operator-= | ( | const dynamic_bitset< _WordT, _Alloc > & | __rhs | ) |

inline

Operations on dynamic_bitsets.

Parameters

  __rhs | A same-sized dynamic_bitset.

These should be self-explanatory.

Definition at line 789 of file dynamic_bitset.

References dynamic_bitset().

## operator<<()

template<typename _WordT = unsigned long long, typename _Alloc = std::allocator<_WordT>>

dynamic_bitset std::tr2::dynamic_bitset< _WordT, _Alloc >::operator<< | ( | size_type | __pos | ) | const

inline

Self-explanatory.

Definition at line 1056 of file dynamic_bitset.

References dynamic_bitset().

## operator<<=()

template<typename _WordT = unsigned long long, typename _Alloc = std::allocator<_WordT>>

dynamic_bitset & std::tr2::dynamic_bitset< _WordT, _Alloc >::operator<<= | ( | size_type | __pos | ) |

inline

Operations on dynamic_bitsets.

Parameters

  __pos | The number of places to shift.

These should be self-explanatory.

Definition at line 803 of file dynamic_bitset.

References dynamic_bitset().

## operator=() [1/2]

template<typename _WordT = unsigned long long, typename _Alloc = std::allocator<_WordT>>

dynamic_bitset & std::tr2::dynamic_bitset< _WordT, _Alloc >::operator= | ( | const dynamic_bitset< _WordT, _Alloc > & |  | ) |

default

Copy assignment operator.

References dynamic_bitset().

## operator=() [2/2]

template<typename _WordT = unsigned long long, typename _Alloc = std::allocator<_WordT>>

dynamic_bitset & std::tr2::dynamic_bitset< _WordT, _Alloc >::operator= | ( | dynamic_bitset< _WordT, _Alloc > && | __b | ) |

inline noexcept

Move assignment operator.

Definition at line 667 of file dynamic_bitset.

References dynamic_bitset(), and get_allocator().

## operator>>()

template<typename _WordT = unsigned long long, typename _Alloc = std::allocator<_WordT>>

dynamic_bitset std::tr2::dynamic_bitset< _WordT, _Alloc >::operator>> | ( | size_type | __pos | ) | const

inline

Self-explanatory.

Definition at line 1061 of file dynamic_bitset.

References dynamic_bitset().

## operator>>=()

template<typename _WordT = unsigned long long, typename _Alloc = std::allocator<_WordT>>

dynamic_bitset & std::tr2::dynamic_bitset< _WordT, _Alloc >::operator>>= | ( | size_type | __pos | ) |

inline

Operations on dynamic_bitsets.

Parameters

  __pos | The number of places to shift.

These should be self-explanatory.

Definition at line 817 of file dynamic_bitset.

## operator[]() [1/2]

template<typename _WordT = unsigned long long, typename _Alloc = std::allocator<_WordT>>

reference std::tr2::dynamic_bitset< _WordT, _Alloc >::operator[] | ( | size_type | __pos | ) |

inline

Array-indexing support.

Parameters

  __pos | Index into the dynamic_bitset.

Returns
  A bool for a 'const dynamic_bitset'. For non-const bitsets, an instance of the reference proxy class.

Note
  These operators do no range checking and throw no exceptions, as required by DR 11 to the standard.

Definition at line 917 of file dynamic_bitset.

## operator[]() [2/2]

template<typename _WordT = unsigned long long, typename _Alloc = std::allocator<_WordT>>

const_reference std::tr2::dynamic_bitset< _WordT, _Alloc >::operator[] | ( | size_type | __pos | ) | const

inline

Array-indexing support.

Parameters

  __pos | Index into the dynamic_bitset.

Returns
  A bool for a 'const dynamic_bitset'. For non-const bitsets, an instance of the reference proxy class.

Note
  These operators do no range checking and throw no exceptions, as required by DR 11 to the standard.

Definition at line 921 of file dynamic_bitset.

## operator^=()

template<typename _WordT = unsigned long long, typename _Alloc = std::allocator<_WordT>>

dynamic_bitset & std::tr2::dynamic_bitset< _WordT, _Alloc >::operator^= | ( | const dynamic_bitset< _WordT, _Alloc > & | __rhs | ) |

inline

Operations on dynamic_bitsets.

Parameters

  __rhs | A same-sized dynamic_bitset.

These should be self-explanatory.

Definition at line 782 of file dynamic_bitset.

References dynamic_bitset().

## operator|=()

template<typename _WordT = unsigned long long, typename _Alloc = std::allocator<_WordT>>

dynamic_bitset & std::tr2::dynamic_bitset< _WordT, _Alloc >::operator|= | ( | const dynamic_bitset< _WordT, _Alloc > & | __rhs | ) |

inline

Operations on dynamic_bitsets.

Parameters

  __rhs | A same-sized dynamic_bitset.

These should be self-explanatory.

Definition at line 775 of file dynamic_bitset.

References dynamic_bitset().

## operator~()

template<typename _WordT = unsigned long long, typename _Alloc = std::allocator<_WordT>>

dynamic_bitset std::tr2::dynamic_bitset< _WordT, _Alloc >::operator~ | ( |  | ) | const

inline

See the no-argument flip().

Definition at line 904 of file dynamic_bitset.

References dynamic_bitset(), and flip().

## push_back()

template<typename _WordT = unsigned long long, typename _Alloc = std::allocator<_WordT>>

void std::tr2::dynamic_bitset< _WordT, _Alloc >::push_back | ( | bool | __bit | ) |

inline

Push a bit onto the high end of the bitset.

Definition at line 713 of file dynamic_bitset.

References size().

## reset() [1/2]

template<typename _WordT = unsigned long long, typename _Alloc = std::allocator<_WordT>>

dynamic_bitset & std::tr2::dynamic_bitset< _WordT, _Alloc >::reset | ( |  | ) |

inline

Sets every bit to false.

Definition at line 857 of file dynamic_bitset.

## reset() [2/2]

template<typename _WordT = unsigned long long, typename _Alloc = std::allocator<_WordT>>

dynamic_bitset & std::tr2::dynamic_bitset< _WordT, _Alloc >::reset | ( | size_type | __pos | ) |

inline

Sets a given bit to false.

Parameters

  __pos | The index of the bit.

Exceptions

  std::out_of_range | If __pos is bigger the size of the set.

Same as writing `set(__pos, false)`.

Definition at line 871 of file dynamic_bitset.

## resize()

template<typename _WordT = unsigned long long, typename _Alloc = std::allocator<_WordT>>

void std::tr2::dynamic_bitset< _WordT, _Alloc >::resize | ( | size_type | __nbits,
|  | bool | __value = false )

inline

Resize the bitset.

Definition at line 690 of file dynamic_bitset.

Referenced by std::tr2::operator>>().

## set() [1/2]

template<typename _WordT = unsigned long long, typename _Alloc = std::allocator<_WordT>>

dynamic_bitset & std::tr2::dynamic_bitset< _WordT, _Alloc >::set | ( |  | ) |

inline

Sets every bit to true.

Definition at line 832 of file dynamic_bitset.

## set() [2/2]

template<typename _WordT = unsigned long long, typename _Alloc = std::allocator<_WordT>>

dynamic_bitset & std::tr2::dynamic_bitset< _WordT, _Alloc >::set | ( | size_type | __pos,
|  | bool | __val = true )

inline

Sets a given bit to a particular value.

Parameters

  __pos | The index of the bit.
  __val | Either true or false, defaults to true.

Exceptions

  std::out_of_range | If __pos is bigger the size of the set.

Definition at line 846 of file dynamic_bitset.

## size()

template<typename _WordT = unsigned long long, typename _Alloc = std::allocator<_WordT>>

size_type std::tr2::dynamic_bitset< _WordT, _Alloc >::size | ( |  | ) | const

inline noexcept

Returns the total number of bits.

Definition at line 996 of file dynamic_bitset.

Referenced by std::tr2::operator>>(), and push_back().

## swap()

template<typename _WordT = unsigned long long, typename _Alloc = std::allocator<_WordT>>

void std::tr2::dynamic_bitset< _WordT, _Alloc >::swap | ( | dynamic_bitset< _WordT, _Alloc > & | __b | ) |

inline noexcept

Swap with another bitset.

Definition at line 656 of file dynamic_bitset.

References dynamic_bitset().

## test()

template<typename _WordT = unsigned long long, typename _Alloc = std::allocator<_WordT>>

bool std::tr2::dynamic_bitset< _WordT, _Alloc >::test | ( | size_type | __pos | ) | const

inline

Tests the value of a bit.

Parameters

  __pos | The index of a bit.

Returns
  The value at __pos.

Exceptions

  std::out_of_range | If __pos is bigger the size of the set.

Definition at line 1023 of file dynamic_bitset.

## to_string()

template<typename _WordT = unsigned long long, typename _Alloc = std::allocator<_WordT>>
template<typename _CharT = char, typename _Traits = std::char_traits<_CharT>, typename _Alloc1 = std::allocator<_CharT>>

std::basic_string< _CharT, _Traits, _Alloc1 > std::tr2::dynamic_bitset< _WordT, _Alloc >::to_string | ( | _CharT | __zero = _CharT('0'),
|  | _CharT | __one = _CharT('1') ) const

inline

Returns a character interpretation of the dynamic_bitset.

Returns
  The string equivalent of the bits.

Note the ordering of the bits: decreasing character positions correspond to increasing bit positions (see the main class notes for an example).

Definition at line 957 of file dynamic_bitset.

## to_ullong()

template<typename _WordT = unsigned long long, typename _Alloc = std::allocator<_WordT>>

unsigned long long std::tr2::dynamic_bitset< _WordT, _Alloc >::to_ullong | ( |  | ) | const

inline

Returns a numerical interpretation of the dynamic_bitset.

Returns
  The integral equivalent of the bits.

Exceptions

  std::overflow_error | If there are too many bits to be represented in an `unsigned` `long`.

Definition at line 942 of file dynamic_bitset.

## to_ulong()

template<typename _WordT = unsigned long long, typename _Alloc = std::allocator<_WordT>>

unsigned long std::tr2::dynamic_bitset< _WordT, _Alloc >::to_ulong | ( |  | ) | const

inline

Returns a numerical interpretation of the dynamic_bitset.

Returns
  The integral equivalent of the bits.

Exceptions

  std::overflow_error | If there are too many bits to be represented in an `unsigned` `long`.

Definition at line 932 of file dynamic_bitset.

## Friends And Related Symbol Documentation

## operator<

template<typename _WordT = unsigned long long, typename _Alloc = std::allocator<_WordT>>

bool operator< | ( | const dynamic_bitset< _WordT, _Alloc > & | __lhs,
|  | const dynamic_bitset< _WordT, _Alloc > & | __rhs )

friend

Definition at line 1097 of file dynamic_bitset.

## operator==

template<typename _WordT = unsigned long long, typename _Alloc = std::allocator<_WordT>>

bool operator== | ( | const dynamic_bitset< _WordT, _Alloc > & | __lhs,
|  | const dynamic_bitset< _WordT, _Alloc > & | __rhs )

friend

Definition at line 1093 of file dynamic_bitset.

## reference

template<typename _WordT = unsigned long long, typename _Alloc = std::allocator<_WordT>>

friend class reference

friend

Definition at line 569 of file dynamic_bitset.

## Member Data Documentation

## bits_per_block

template<typename _WordT = unsigned long long, typename _Alloc = std::allocator<_WordT>>

const size_type std::tr2::dynamic_bitset< _WordT, _Alloc >::bits_per_block

static

Definition at line 434 of file dynamic_bitset.

## npos

template<typename _WordT = unsigned long long, typename _Alloc = std::allocator<_WordT>>

const size_type std::tr2::dynamic_bitset< _WordT, _Alloc >::npos

static

Definition at line 436 of file dynamic_bitset.

The documentation for this class was generated from the following files:

- dynamic_bitset
- dynamic_bitset.tcc