|
| dynamic_bitset ()=default |
|
| dynamic_bitset (const allocator_type &__alloc) |
|
| dynamic_bitset (size_type __nbits, unsigned long long __val=0ULL, const allocator_type &__alloc=allocator_type()) |
|
| dynamic_bitset (initializer_list< block_type > __il, const allocator_type &__alloc=allocator_type()) |
|
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 (const char *__str, const allocator_type &__alloc=allocator_type()) |
|
| dynamic_bitset (const dynamic_bitset &)=default |
|
| dynamic_bitset (dynamic_bitset &&__b) noexcept |
|
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 |
|
void | append (block_type __block) |
|
void | append (initializer_list< block_type > __il) |
|
template<typename _BlockInputIterator > |
void | append (_BlockInputIterator __first, _BlockInputIterator __last) |
|
void | clear () |
|
size_type | count () const noexcept |
|
_GLIBCXX_NODISCARD 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 |
|
|
size_t | _M_are_all_aux () const noexcept |
|
void | _M_clear () noexcept |
|
void | _M_do_and (const __dynamic_bitset_base &__x) noexcept |
|
void | _M_do_append_block (block_type __block, size_type __pos) |
|
size_t | _M_do_count () const noexcept |
|
void | _M_do_dif (const __dynamic_bitset_base &__x) noexcept |
|
size_type | _M_do_find_first (size_t __not_found) const |
|
size_type | _M_do_find_next (size_t __prev, size_t __not_found) const |
|
void | _M_do_flip () noexcept |
|
void | _M_do_left_shift (size_t __shift) |
|
void | _M_do_or (const __dynamic_bitset_base &__x) noexcept |
|
void | _M_do_reset () noexcept |
|
void | _M_do_right_shift (size_t __shift) |
|
void | _M_do_set () noexcept |
|
unsigned long long | _M_do_to_ullong () const |
|
unsigned long | _M_do_to_ulong () const |
|
void | _M_do_xor (const __dynamic_bitset_base &__x) noexcept |
|
allocator_type | _M_get_allocator () const noexcept |
|
block_type & | _M_getword (size_type __pos) noexcept |
|
block_type | _M_getword (size_type __pos) const noexcept |
|
block_type & | _M_hiword () noexcept |
|
block_type | _M_hiword () const noexcept |
|
bool | _M_is_any () const noexcept |
|
bool | _M_is_equal (const __dynamic_bitset_base &__x) const noexcept |
|
bool | _M_is_less (const __dynamic_bitset_base &__x) const noexcept |
|
bool | _M_is_proper_subset_of (const __dynamic_bitset_base &__b) const noexcept |
|
bool | _M_is_subset_of (const __dynamic_bitset_base &__b) noexcept |
|
void | _M_resize (size_t __nbits, bool __value) |
|
size_type | _M_size () const noexcept |
|
void | _M_swap (__dynamic_bitset_base &__b) noexcept |
|
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;
}
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 419 of file dynamic_bitset.