STD::TR2::DYNAMIC_BITSET(3)
π std::tr2::dynamic_bitset< _WordT, _Alloc > β Library Functions Manual π
β¨ NAME β¨
std::tr2::dynamic_bitset< _WordT, _Alloc > β the dynamic_bitset class represents a sequence of bits. That's the whole vibe. No cap. π
πΈ SYNOPSIS πΈ
okay bestie, first things first, you include this:
#include <dynamic_bitset>
Inherits std::tr2::__dynamic_bitset_base< _WordT, _Alloc >. Main character energy inherited, fr fr.
π Classes
class reference
π§ Public Types
typedef __dynamic_bitset_base< _WordT, _Alloc > _Basetypedef _Alloc allocator_typetypedef _WordT block_typetypedef bool const_referencetypedef size_t size_type
π Public Member Functions
okay bestie, here's the whole roster. Every single one. Don't skip. π
dynamic_bitset ()=defaultβ all bits set to zero.dynamic_bitset (const allocator_type &__alloc)β all bits set to zero.dynamic_bitset (const char *__str, const allocator_type &__alloc=allocator_type())β construct from a string.dynamic_bitset (const dynamic_bitset &)=defaultβ copy constructor.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())β use a subset of a string.dynamic_bitset (dynamic_bitset &&__b) noexceptβ move constructor.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())β initial bits bitwise-copied from a single word (others set to zero).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')) constbool all () constβ tests whether all the bits are on.bool any () constβ tests whether any of the bits are on.template<typename _BlockInputIterator> void append (_BlockInputIterator __first, _BlockInputIterator __last)β append an iterator range of blocks.void append (block_type __block)β append a block.void append (initializer_list< block_type > __il)void clear ()β clear the bitset.size_type count () const noexceptβ returns the number of bits which are set.bool empty () const noexceptβ returns true if the dynamic_bitset is empty.size_type find_first () constβ finds the index of the first on bit.size_type find_next (size_t __prev) constβ finds the index of the next on bit after__prev.dynamic_bitset & flip ()β toggles every bit to its opposite value.dynamic_bitset & flip (size_type __pos)β toggles a given bit to its opposite value.allocator_type get_allocator () const noexceptβ return the allocator for the bitset.bool is_proper_subset_of (const dynamic_bitset &__b) constbool is_subset_of (const dynamic_bitset &__b) constconstexpr size_type max_size () noexceptβ returns the maximum size of a dynamic_bitset object having the same type as*this. The real answer ismax() * bits_per_blockbut is likely to overflow.bool none () constβ tests whether any of the bits are on.size_type num_blocks () const noexceptβ returns the total number of blocks.dynamic_bitset & operator= (const dynamic_bitset &)=defaultβ copy assignment operator.dynamic_bitset & operator= (dynamic_bitset &&__b) noexcept(std::is_nothrow_move_assignable< _Base >::value)β move assignment operator.dynamic_bitset operator~ () constβ see the no-argumentflip().void push_back (bool __bit)β push a bit onto the high end of the bitset.dynamic_bitset & reset ()β sets every bit to false.dynamic_bitset & reset (size_type __pos)β sets a given bit to false.void resize (size_type __nbits, bool __value=false)β resize the bitset.dynamic_bitset & set ()β sets every bit to true.dynamic_bitset & set (size_type __pos, bool __val=true)β sets a given bit to a particular value.size_type size () const noexceptβ returns the total number of bits.void swap (dynamic_bitset &__b) noexceptβ swap with another bitset.bool test (size_type __pos) constβ tests the value of a bit.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β returns a character interpretation of the dynamic_bitset.unsigned long long to_ullong () constβ returns a numerical interpretation of the dynamic_bitset.unsigned long to_ulong () constβ returns a numerical interpretation of the dynamic_bitset.
and the operator overloads, still part of Public Member Functions, operations on dynamic_bitsets. β¨
dynamic_bitset & operator&= (const dynamic_bitset &__rhs)β operations on dynamic_bitsets.dynamic_bitset & operator&= (dynamic_bitset &&__rhs)β operations on dynamic_bitsets.dynamic_bitset & operator|= (const dynamic_bitset &__rhs)β operations on dynamic_bitsets.dynamic_bitset & operator^= (const dynamic_bitset &__rhs)β operations on dynamic_bitsets.dynamic_bitset & operator-= (const dynamic_bitset &__rhs)β operations on dynamic_bitsets.dynamic_bitset & operator<<= (size_type __pos)β operations on dynamic_bitsets.dynamic_bitset & operator>>= (size_type __pos)β operations on dynamic_bitsets.reference operator[] (size_type __pos)β array-indexing support.const_reference operator[] (size_type __pos) constβ array-indexing support.dynamic_bitset operator<< (size_type __pos) constβ self-explanatory.dynamic_bitset operator>> (size_type __pos) constβ self-explanatory.
π Static Public Attributes
static const size_type bits_per_blockstatic const size_type npos
π«Ά Friends
bool operator< (const dynamic_bitset &__lhs, const dynamic_bitset &__rhs) noexceptbool operator== (const dynamic_bitset &__lhs, const dynamic_bitset &__rhs) noexceptclass reference
π₯ Detailed Description π₯
okay so now the deep lore. vibe check passed. π¦
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. It's giving bit sequence realness. π
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.
π Constructor & Destructor Documentation π
okay so this is the part where we meet the constructors β the lil glow-ups that make a brand-new dynamic_bitset appear out of thin air β¨ every single one of them, no skips, let's go π«Ά
πΌ dynamic_bitset() β the default one
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. she comes out the gate all zeros, iconic π
Referenced by dynamic_bitset(), dynamic_bitset(), operator&=(), operator&=(), operator-=(), operator<<(), operator<<=(), operator=(), operator=(), operator>>(), operator^=(), operator|=(), operator~(), and swap().
π dynamic_bitset(const allocator_type & __alloc)
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. (same energy, but now you're picking the allocator π§)
πΈ dynamic_bitset(size_type __nbits, unsigned long long __val = 0ULL, const allocator_type & __alloc = allocator_type())
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). so you hand her one word and she copies it in bit by bit, and everything past that is just zeros π
π¦ dynamic_bitset from a basic_string (the template girlies)
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. you're literally just taking a slice of the string and turning it into bits, obsessed π
Parameters
__strβ A string of '0' and '1' characters.__posβ Index of the first character in__strto 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__posis bigger the size of__str.std::invalid_argumentβ If a character appears in the string which is neither '0' nor '1'.
References std::basic_string< _CharT, _Traits, _Alloc >::npos, and std::basic_string< _CharT, _Traits, _Alloc >::size().
π dynamic_bitset(const char * __str, const allocator_type & __alloc = allocator_type())
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. the C-string version, lowkey convenient ngl π
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'.
π dynamic_bitset(const dynamic_bitset< _WordT, _Alloc > & ) β copy constructor
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. twin where have you been π«Ά
References dynamic_bitset().
π dynamic_bitset(dynamic_bitset< _WordT, _Alloc > && __b) β move constructor
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. no copy, she just relocates, main character energy fr fr π₯
References dynamic_bitset(), and std::move().
β¨ Member Function Documentation β¨
π all() const
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. every single one, bestie, no stragglers π
Returns
True if all the bits are set.
π any() const
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. literally just needs one π₯Ί
Returns
True if at least one bit is set.
π append(_BlockInputIterator __first, _BlockInputIterator __last)
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. give her a whole range and she'll tack it on the end π
References append().
π append(block_type __block)
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. one block at a time, we love a slow build π¦
Referenced by append().
π§Ή clear()
template<typename _WordT = unsigned long long, typename _Alloc = std::allocator<_WordT>>
void std::tr2::dynamic_bitset< _WordT, _Alloc >::clear () [inline]
Clear the bitset. bye bye bits π
π’ count() const
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. the set-bit census π
π«§ empty() const
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. note the [nodiscard] β do not ignore this return value, she will know π
π find_first() const
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. first one to raise their hand πββοΈ
Returns
The index of the first bit set, or size() if not found.
See also
find_next
π find_next(size_t __prev) const
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. the sequel π«
Returns
The index of the next bit set, or size() if not found.
Parameters
__prevβ Where to start searching.
See also
find_first
π flip()
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. everyone swap sides, no survivors π₯
Referenced by operator~().
π flip(size_type __pos)
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. just the one, targeted chaos π
Parameters
__posβ The index of the bit.
Exceptions
std::out_of_rangeβ If__posis bigger the size of the set.
π get_allocator() const
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. she'll hand you back her allocator, no questions π«Ά
Referenced by operator=().
π 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. so like, the honest answer is a number that probably won't fit π noted, we respect the warning.
References std::numeric_limits< _Tp >::max().
π
ββοΈ none() const
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. (yes bestie, the description really does say that π)
Returns
True if none of the bits are set.
π§± num_blocks() const
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. the block count, periodt π§±
βοΈ operator&=(const dynamic_bitset< _WordT, _Alloc > & __rhs)
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. π
References dynamic_bitset().
βοΈ operator&=(dynamic_bitset< _WordT, _Alloc > && __rhs)
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. π
References dynamic_bitset(), and std::move().
β operator-=(const dynamic_bitset< _WordT, _Alloc > & __rhs)
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. π
References dynamic_bitset().
β¬
οΈ operator<<(size_type __pos) const
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. (the manpage said it, not me π)
References dynamic_bitset().
β¬
οΈ operator<<=(size_type __pos)
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. π
References dynamic_bitset().
π operator=(const dynamic_bitset< _WordT, _Alloc > & )
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. matching her energy and copying the whole fit π
References dynamic_bitset().
π operator=(dynamic_bitset< _WordT, _Alloc > && __b)
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. she takes what's yours and makes it hers, gracefully π
References dynamic_bitset(), and get_allocator().
β‘οΈ operator>>(size_type __pos) const
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. (again, their words π)
References dynamic_bitset().
β‘οΈ operator>>=(size_type __pos)
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. π
π― operator[](size_type __pos)
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. yes bestie, you can just go in there and index her π
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.
π operator[] β the const one π
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]
Bestie, this is your array-indexing support. Yes, the bitset gets to pretend it's an array. Iconic behaviour honestly.
Parameters
__posβ the index you're poking into the dynamic_bitset.
Returns
- A
boolfor aconst dynamic_bitset. But for non-const bitsets you get an instance of the reference proxy class instead. So likeβ¦ it depends on the vibe of your object. π
Note: these operators do no range checking and throw no exceptions, as required by DR 11 to the standard. So it's giving "trust me bro" energy β you go out of bounds, that's on you. π
π operator^= β XOR, but make it in-place
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, bestie. This is the XOR-and-assign one.
Parameters
__rhsβ a same-sized dynamic_bitset. Same size, okay? Not playing about that.
These should be self-explanatory. fr fr, no notes. π«Ά
References: dynamic_bitset().
β¨ operator|= β OR, but make it in-place
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, again. This one ORs and assigns.
Parameters
__rhsβ a same-sized dynamic_bitset.
These should be self-explanatory. periodt. π
References: dynamic_bitset().
π¦ operator~ β the flip girlie
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(). That's the whole thing, that's the tweet.
References: dynamic_bitset(), and flip().
π push_back β new bit, who dis
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. Like adding a little star to the end of your row of stars. β
References: size().
π§ reset() β everyone to false, now
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. The whole bitset, wiped, clean slate, main character rebrand. π
π reset (size_type __pos) β just the one bit to false
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__posis bigger the size of the set. Yes, this one does check, unlike thoseoperator[]gremlins.
Same as writing set(__pos, false). Literally the same thing, just cuter to type. π
πΈ resize β glow-up or shrink, your call
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. That's it, that's the description, she's simple and she's serving. π
Referenced by std::tr2::operator>>().
π set() β everyone to true
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. The opposite of reset(), obviously. Full send. π₯
β set (size_type __pos, bool __val = true) β one bit, one value
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. Picky, specific, we love her.
Parameters
__posβ the index of the bit.__valβ eithertrueorfalse, defaults totrue.
Exceptions
std::out_of_rangeβ if__posis bigger the size of the set.
π size β how many bits, bestie
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. And she's noexcept, so she will not be throwing hands today. π
Referenced by std::tr2::operator>>(), and push_back().
π
swap β trade places, no drama
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. Two bitsets, one swap, everyone goes home happy. Also noexcept, because she's unbothered. π«Ά
References: dynamic_bitset().
π§ test β vibe check on one bit
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. A real vibe check, for real for real.
Parameters
__posβ the index of a bit.
Returns
- The value at
__pos.
Exceptions
std::out_of_rangeβ if__posis bigger the size of the set.
π to_string β bits, but make them characters
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. She's translating bits into letters, multilingual queen. β¨
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. So like, the string reads "backwards" relative to the bit indices. Don't come for me, that's just how she is. π
π to_ullong β bits, but a number
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. unsigned long long flavoured. π’
Returns
- The integral equivalent of the bits.
Exceptions
std::overflow_errorβ if there are too many bits to be represented in anunsigned long.
π to_ulong β bits, but a smaller number
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. Same energy as to_ullong, smaller container. π
Returns
- The integral equivalent of the bits.
Exceptions
std::overflow_errorβ if there are too many bits to be represented in anunsigned long.
π AUTHOR π
Generated automatically by Doxygen for libstdc++ from the source code. Not a human, not a vibe, just a robot doing its little robot thing and honestly? Ate. π€β¨
And that's a wrap on this one, bestie π«Ά β shoutout to libstdc++ for the source and version info down in the footer, and to whatever date stamp is chilling down there too. Go forth and bitset responsibly. πππ¦
π¦ where this page comes from
- arch rolling: gcc 16.2.1+r23+gd564253eb6c8-1 Β· GPL-3.0-or-later WITH GCC-exception-3.1 AND GFDL-1.3-or-later
- fedora 44: libstdc++-docs 16.0.1-0.10.fc44 Β· GPL-3.0-or-later AND LGPL-3.0-or-later AND (GPL-3.0-or-later WITH GCC-exception-3.1) AND (GPL-3.0-or-later WITH Texinfo-exception) AND (LGPL-2.1-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GNU-compiler-exception) AND BSL-1.0 AND GFDL-1.3-or-later AND Linux-man-pages-copyleft-2-para AND SunPro AND BSD-1-Clause AND BSD-2-Clause AND BSD-2-Clause-Views AND BSD-3-Clause AND BSD-4-Clause AND BSD-Source-Code AND Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 WITH LLVM-Exception) AND ZPL-2.1 AND ISC AND LicenseRef-Fedora-Public-Domain AND HP-1986 AND curl AND Martin-Birgmeier AND HPND-Markus-Kuhn AND dtoa AND SMLNJ AND AMD-newlib AND OAR AND HPND-merchantability-variant AND HPND-Intel
- fedora 44: libstdc++-docs 16.2.1-2.fc44
- fedora 44: libstdc++-docs 16.2.1-3.fc44 Β· GPL-3.0-or-later AND LGPL-3.0-or-later AND (GPL-3.0-or-later WITH GCC-exception-3.1) AND (GPL-3.0-or-later WITH Texinfo-exception) AND (LGPL-2.1-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GNU-compiler-exception) AND BSL-1.0 AND GFDL-1.3-or-later AND Linux-man-pages-copyleft-2-para AND SunPro AND BSD-1-Clause AND BSD-2-Clause AND BSD-2-Clause-Views AND BSD-3-Clause AND BSD-4-Clause AND BSD-Source-Code AND Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 WITH LLVM-Exception) AND ZPL-2.1 AND ISC AND LicenseRef-Fedora-Public-Domain AND HP-1986 AND curl AND Martin-Birgmeier AND HPND-Markus-Kuhn AND dtoa AND SMLNJ AND AMD-newlib AND OAR AND HPND-merchantability-variant AND HPND-Intel
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms