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 > _Base
  • typedef _Alloc allocator_type
  • typedef _WordT block_type
  • typedef bool const_reference
  • typedef 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')) const
  • bool 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) const
  • bool is_subset_of (const dynamic_bitset &__b) const
  • constexpr size_type max_size () 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.
  • 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-argument flip().
  • 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_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 πŸ”₯

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 __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'.

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 __pos is 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 bool for a const 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 __pos is bigger the size of the set. Yes, this one does check, unlike those operator[] 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 β€” either true or false, defaults to true.

Exceptions

  • std::out_of_range β€” if __pos is 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 __pos is 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 an unsigned 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 an unsigned 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