### Example: Constructing dynamic_bitset from Integral Type Source: https://github.com/boostorg/dynamic_bitset/blob/develop/dynamic_bitset.html Demonstrates the behavior of the BlockInputIterator constructor when the iterator type is actually an integral type. It constructs a bitset of size 8 initialized from the value 7. ```C++ dynamic_bitset b(8, 7); ``` -------------------------------- ### Getting Allocator from Boost Dynamic Bitset C++ Source: https://github.com/boostorg/dynamic_bitset/blob/develop/dynamic_bitset.html Returns a copy of the allocator object that was used to construct the current bitset. ```C++ allocator_type get_allocator() const; ``` -------------------------------- ### Setting/Clearing Bit and Getting Previous State - Boost dynamic_bitset - C++ Source: https://github.com/boostorg/dynamic_bitset/blob/develop/dynamic_bitset.html Sets or clears bit `n` based on `val`. Returns the previous state of bit `n`. Requires `n` to be less than the bitset size. ```C++ bool test_set(size_type n, bool val = true) ``` -------------------------------- ### Getting Size of Boost Dynamic Bitset C++ Source: https://github.com/boostorg/dynamic_bitset/blob/develop/dynamic_bitset.html Returns the current number of bits stored in the bitset. This operation does not throw exceptions. ```C++ size_type size() const ``` -------------------------------- ### Getting Number of Blocks in Boost Dynamic Bitset C++ Source: https://github.com/boostorg/dynamic_bitset/blob/develop/dynamic_bitset.html Returns the number of underlying blocks used to store the bits in the bitset. This operation does not throw exceptions. ```C++ size_type num_blocks() const ``` -------------------------------- ### Constructing dynamic_bitset: Move Constructor Source: https://github.com/boostorg/dynamic_bitset/blob/develop/dynamic_bitset.html Constructs a new dynamic_bitset by moving resources from an existing dynamic_bitset. The new bitset will be the same as the source, and its allocator will be moved from the source's allocator. ```C++ dynamic_bitset(dynamic_bitset&& x) ``` -------------------------------- ### Constructing dynamic_bitset: Copy Constructor Source: https://github.com/boostorg/dynamic_bitset/blob/develop/dynamic_bitset.html Constructs a new dynamic_bitset that is a copy of an existing dynamic_bitset. The new bitset will have the same size and bit values as the source, and its allocator will be a copy of the source's allocator. This constructor is required by the Assignable concept. ```C++ dynamic_bitset(const dynamic_bitset& x) ``` -------------------------------- ### Boost dynamic_bitset Class Template Definition Source: https://github.com/boostorg/dynamic_bitset/blob/develop/dynamic_bitset.html Defines the Boost dynamic_bitset class template, including its template parameters, nested types, static constants, nested reference class, constructors, and member function declarations. ```C++ namespace boost { template class dynamic_bitset { public: typedef Block block_type; typedef Allocator allocator_type; typedef _implementation-defined_ size_type; static const int bits_per_block = _implementation-defined_; static const size_type npos = _implementation-defined_; class reference { void operator&(); // not defined public: // An automatically generated copy constructor. reference& operator=(bool value); reference& operator=(const reference& rhs); reference& operator|=(bool value); reference& operator&=(bool value); reference& operator^=(bool value); reference& operator-=(bool value); bool operator~() const; operator bool() const; reference& flip(); }; typedef bool const_reference; dynamic_bitset(); explicit dynamic_bitset(const Allocator& alloc); explicit dynamic_bitset(size_type num_bits, unsigned long value = 0, const Allocator& alloc = Allocator()); template explicit dynamic_bitset(const std::basic_string& s, typename std::basic_string::size_type pos = 0, typename std::basic_string::size_type n = std::basic_string::npos, const Allocator& alloc = Allocator()); template dynamic_bitset(BlockInputIterator first, BlockInputIterator last, const Allocator& alloc = Allocator()); dynamic_bitset(const dynamic_bitset& b); dynamic_bitset(dynamic_bitset&& b); void swap(dynamic_bitset& b); dynamic_bitset& operator=(const dynamic_bitset& b); dynamic_bitset& operator=(dynamic_bitset&& b); allocator_type get_allocator() const; void resize(size_type num_bits, bool value = false); void clear(); void pop_back(); void push_back(bool bit); void append(Block block); template void append(BlockInputIterator first, BlockInputIterator last); dynamic_bitset& operator&=(const dynamic_bitset& b); dynamic_bitset& operator|=(const dynamic_bitset& b); dynamic_bitset& operator^=(const dynamic_bitset& b); dynamic_bitset& operator-=(const dynamic_bitset& b); dynamic_bitset& operator<<=(size_type n); dynamic_bitset& operator>>=(size_type n); dynamic_bitset operator<<(size_type n) const; dynamic_bitset operator>>(size_type n) const; dynamic_bitset& set(size_type n, size_type len, bool val); dynamic_bitset& set(size_type n, bool val = true); dynamic_bitset& set(); dynamic_bitset& reset(size_type n, size_type len); dynamic_bitset& reset(size_type n); dynamic_bitset& reset(); dynamic_bitset& flip(size_type n, size_type len); dynamic_bitset& flip(size_type n); dynamic_bitset& flip(); reference at(size_type n); bool at(size_type n) const; bool test(size_type n) const; bool test_set(size_type n, bool val = true); bool all() const; bool any() const; bool none() const; dynamic_bitset operator~() const; size_type count() const noexcept; reference operator[](size_type pos); bool operator[](size_type pos) const; unsigned long to_ulong() const; size_type size() const noexcept; size_type num_blocks() const noexcept; size_type max_size() const noexcept; bool empty() const noexcept; size_type capacity() const noexcept; void reserve(size_type num_bits); void shrink_to_fit(); bool is_subset_of(const dynamic_bitset& a) const; bool is_proper_subset_of(const dynamic_bitset& a) const; bool intersects(const dynamic_bitset& a) const; size_type find_first() const; size_type find_first(size_type pos) const; size_type find_next(size_type pos) const; }; ``` -------------------------------- ### Setting All Bits in Boost Dynamic Bitset C++ Source: https://github.com/boostorg/dynamic_bitset/blob/develop/dynamic_bitset.html Sets every bit in the current bitset to 1. Returns a reference to the current bitset and does not throw exceptions. ```C++ dynamic_bitset& set() ``` -------------------------------- ### Finding First Set Bit - Boost dynamic_bitset - C++ Source: https://github.com/boostorg/dynamic_bitset/blob/develop/dynamic_bitset.html Finds the index of the first (lowest) set bit. Returns the index of the lowest set bit, or `npos` if no bits are set. ```C++ size_type find_first() const; ``` -------------------------------- ### Constructing dynamic_bitset: From Integer Value Source: https://github.com/boostorg/dynamic_bitset/blob/develop/dynamic_bitset.html Constructs a dynamic_bitset of a specified size, initializing the least significant bits from an unsigned long value. The remaining bits are set to zero. An optional allocator can be provided. ```C++ dynamic_bitset(size_type num_bits, unsigned long value = 0, const Allocator& alloc = Allocator()) ``` -------------------------------- ### Finding First Set Bit from Position - Boost dynamic_bitset - C++ Source: https://github.com/boostorg/dynamic_bitset/blob/develop/dynamic_bitset.html Finds the index of the first set bit at or after a specified position. Returns the index of the lowest set bit at or after `pos`, or `npos` if no such bit exists. ```C++ size_type find_first(size_type pos) const; ``` -------------------------------- ### Constructing dynamic_bitset: With Allocator Source: https://github.com/boostorg/dynamic_bitset/blob/develop/dynamic_bitset.html Constructs an empty dynamic_bitset of size zero, using a copy of the provided allocator object for subsequent memory management operations like resize. ```C++ dynamic_bitset(const Allocator& alloc) ``` -------------------------------- ### Constructing dynamic_bitset: From String Source: https://github.com/boostorg/dynamic_bitset/blob/develop/dynamic_bitset.html Constructs a dynamic_bitset from a string containing '0' and '1' characters. The string is read from right to left (highest character position corresponds to the least significant bit). An optional substring range and allocator can be specified. ```C++ template explicit dynamic_bitset(const std::basic_string& s, typename std::basic_string::size_type pos = 0, typename std::basic_string::size_type n = std::basic_string::npos, const Allocator& alloc = Allocator()) ``` -------------------------------- ### Constructing dynamic_bitset: Default Constructor Source: https://github.com/boostorg/dynamic_bitset/blob/develop/dynamic_bitset.html Constructs an empty dynamic_bitset with a size of zero using a default-constructed allocator. This constructor is required by the Default Constructible concept. ```C++ dynamic_bitset() ``` -------------------------------- ### Testing Bit State - Boost dynamic_bitset - C++ Source: https://github.com/boostorg/dynamic_bitset/blob/develop/dynamic_bitset.html Tests if bit `n` is set. Returns `true` if bit `n` is 1, `false` if bit `n` is 0. Requires `n` to be less than the bitset size. ```C++ bool test(size_type n) const ``` -------------------------------- ### Write dynamic_bitset to Block Range (C++) Source: https://github.com/boostorg/dynamic_bitset/blob/develop/dynamic_bitset.html Writes the bitset's contents block by block into an output iterator. The first block contains bits [0, bits_per_block), the second [bits_per_block, 2*bits_per_block), etc. Requires the iterator to be an Output Iterator with value_type matching Block and the output range size >= num_blocks(). ```C++ template void to_block_range(const dynamic_bitset& b, BlockOutputIterator result) ``` -------------------------------- ### Flipping All Bits in Boost Dynamic Bitset C++ Source: https://github.com/boostorg/dynamic_bitset/blob/develop/dynamic_bitset.html Flips the value of every bit in the current bitset (0 becomes 1, 1 becomes 0). Returns a reference to the current bitset and does not throw exceptions. ```C++ dynamic_bitset& flip() ``` -------------------------------- ### Swapping Boost Dynamic Bitset C++ Source: https://github.com/boostorg/dynamic_bitset/blob/develop/dynamic_bitset.html Exchanges the contents of the current bitset with another bitset `b`. After the operation, the current bitset holds the original contents of `b`, and `b` holds the original contents of the current bitset. This operation does not throw exceptions. ```C++ void swap(dynamic_bitset& b); ``` -------------------------------- ### Stream Insertion Operator for dynamic_bitset (C++) Source: https://github.com/boostorg/dynamic_bitset/blob/develop/dynamic_bitset.html Inserts a textual representation of the dynamic_bitset into an output stream (highest bit first). The output format is similar to boost::to_string but respects the stream's locale. Returns the output stream. Throws std::ios_base::failure on writing problems. ```C++ template basic_ostream& operator<<(basic_ostream& os, const dynamic_bitset& b) ``` -------------------------------- ### Finding Next Set Bit after Position - Boost dynamic_bitset - C++ Source: https://github.com/boostorg/dynamic_bitset/blob/develop/dynamic_bitset.html Finds the index of the next set bit after a specified position. Returns the index of the lowest set bit greater than `pos`, or `npos` if no such bit exists. ```C++ size_type find_next(size_type pos) const; ``` -------------------------------- ### Copy Assigning Boost Dynamic Bitset C++ Source: https://github.com/boostorg/dynamic_bitset/blob/develop/dynamic_bitset.html Assigns the contents of bitset `x` to the current bitset. After the assignment, the current bitset is a copy of `x`. This operation returns a reference to the current bitset and does not throw exceptions. It is required by the Assignable concept. ```C++ dynamic_bitset& operator=(const dynamic_bitset& x) ``` -------------------------------- ### Move Assigning Boost Dynamic Bitset C++ Source: https://github.com/boostorg/dynamic_bitset/blob/develop/dynamic_bitset.html Moves the contents and resources from bitset `x` to the current bitset. After the operation, the current bitset is the same as `x` was, and `x` is left in a valid but unspecified state. This operation returns a reference to the current bitset and may throw `std::bad_alloc` if memory is exhausted. ```C++ dynamic_bitset& operator=(dynamic_bitset&& x) ``` -------------------------------- ### Constructing dynamic_bitset: From Block Range or Integral Type Source: https://github.com/boostorg/dynamic_bitset/blob/develop/dynamic_bitset.html Constructs a dynamic_bitset from a range of blocks or, if the iterator type is integral, behaves like the constructor from size and unsigned long. Requires the iterator to be an Input Iterator with a value_type matching the block type or an integral type. ```C++ template explicit dynamic_bitset(BlockInputIterator first, BlockInputIterator last, const Allocator& alloc = Allocator()); ``` -------------------------------- ### Boost dynamic_bitset Non-Member Functions Source: https://github.com/boostorg/dynamic_bitset/blob/develop/dynamic_bitset.html Declares non-member functions and operators for the Boost dynamic_bitset class, including comparison, bitwise, stream I/O, and conversion functions. ```C++ template bool operator==(const dynamic_bitset& a, const dynamic_bitset& b); template bool operator!=(const dynamic_bitset& a, const dynamic_bitset& b); template bool operator<(const dynamic_bitset& a, const dynamic_bitset& b); template bool operator<=(const dynamic_bitset& a, const dynamic_bitset& b); template bool operator>(const dynamic_bitset& a, const dynamic_bitset& b); template bool operator>=(const dynamic_bitset& a, const dynamic_bitset& b); template dynamic_bitset operator&(const dynamic_bitset& b1, const dynamic_bitset& b2); template dynamic_bitset operator|(const dynamic_bitset& b1, const dynamic_bitset& b2); template dynamic_bitset operator^(const dynamic_bitset& b1, const dynamic_bitset& b2); template dynamic_bitset operator-(const dynamic_bitset& b1, const dynamic_bitset& b2); template void to_string(const dynamic_bitset& b, std::basic_string& s); template void to_block_range(const dynamic_bitset& b, BlockOutputIterator result); template std::basic_ostream& operator<<(std::basic_ostream& os, const dynamic_bitset& b); template std::basic_istream& operator>>(std::basic_istream& is, dynamic_bitset& b); } // namespace boost ``` -------------------------------- ### Equality Comparison (operator==) - Boost dynamic_bitset - C++ Source: https://github.com/boostorg/dynamic_bitset/blob/develop/dynamic_bitset.html Checks if two bitsets are equal. Returns `true` if they have the same size and all corresponding bits are equal. Requires the `Equality Comparable` concept. ```C++ bool operator==(const dynamic_bitset& rhs) const ``` -------------------------------- ### Flipping Range of Bits in Boost Dynamic Bitset C++ Source: https://github.com/boostorg/dynamic_bitset/blob/develop/dynamic_bitset.html Flips the value of bits (0 becomes 1, 1 becomes 0) in a range from index `n` up to `n + len - 1`. Requires `n + len` to be less than the size of the bitset. Returns a reference to the current bitset. ```C++ dynamic_bitset& flip(size_type n, size_type len) ``` -------------------------------- ### Inequality Comparison (operator!=) - Boost dynamic_bitset - C++ Source: https://github.com/boostorg/dynamic_bitset/blob/develop/dynamic_bitset.html Checks if two bitsets are not equal. Returns `true` if they are not equal (the negation of `operator==`). Requires the `Equality Comparable` concept. ```C++ bool operator!=(const dynamic_bitset& rhs) const ``` -------------------------------- ### Less Than Comparison (operator<) - Boost dynamic_bitset - C++ Source: https://github.com/boostorg/dynamic_bitset/blob/develop/dynamic_bitset.html Performs a lexicographical comparison. Returns `true` if the current bitset is lexicographically less than `rhs`. Requires the `Less Than Comparable` concept. ```C++ bool operator<(const dynamic_bitset& rhs) const ``` -------------------------------- ### Appending Blocks via Iterator to Boost Dynamic Bitset C++ Source: https://github.com/boostorg/dynamic_bitset/blob/develop/dynamic_bitset.html Appends a sequence of blocks from an input iterator range `[first, last)` to the bitset. This is equivalent to repeatedly calling `append(Block)` for each block in the range but is typically more efficient. Requires `BlockInputIterator` to be an Input Iterator with `value_type` equal to `Block`. May throw `std::bad_alloc` if memory is exhausted. ```C++ template void append(BlockInputIterator first, BlockInputIterator last); ``` -------------------------------- ### Accessing Bit (Mutable) via operator[] - Boost dynamic_bitset - C++ Source: https://github.com/boostorg/dynamic_bitset/blob/develop/dynamic_bitset.html Provides a proxy reference to bit `n`, allowing both reading and writing (`b[n] = x` and `x = b[n]`). Requires `n` to be less than the bitset size. The returned type is a proxy, not a direct `bool&`. ```C++ reference operator[](size_type n) ``` -------------------------------- ### Right Shifting Boost Dynamic Bitset C++ Source: https://github.com/boostorg/dynamic_bitset/blob/develop/dynamic_bitset.html Returns a new bitset that is a copy of the current bitset shifted to the right by `n` positions, filling new positions with zero. May throw `std::bad_alloc` if memory is exhausted. ```C++ dynamic_bitset operator>>(size_type n) const ``` -------------------------------- ### Left Shifting Boost Dynamic Bitset C++ Source: https://github.com/boostorg/dynamic_bitset/blob/develop/dynamic_bitset.html Returns a new bitset that is a copy of the current bitset shifted to the left by `n` positions, filling new positions with zero. May throw `std::bad_alloc` if memory is exhausted. ```C++ dynamic_bitset operator<<(size_type n) const ``` -------------------------------- ### Bitwise AND Operator for dynamic_bitset (C++) Source: https://github.com/boostorg/dynamic_bitset/blob/develop/dynamic_bitset.html Performs a bitwise AND operation between two dynamic_bitset objects. Requires both bitsets to have the same size. Returns a new dynamic_bitset representing the result. Throws std::bad_alloc on memory exhaustion. ```C++ dynamic_bitset operator&(const dynamic_bitset& a, const dynamic_bitset& b) ``` -------------------------------- ### Flipping Single Bit in Boost Dynamic Bitset C++ Source: https://github.com/boostorg/dynamic_bitset/blob/develop/dynamic_bitset.html Flips the value of the bit (0 becomes 1, 1 becomes 0) at index `n`. Requires `n` to be less than the size of the bitset. Returns a reference to the current bitset. ```C++ dynamic_bitset& flip(size_type n) ``` -------------------------------- ### Checking for Subset Relationship - Boost dynamic_bitset - C++ Source: https://github.com/boostorg/dynamic_bitset/blob/develop/dynamic_bitset.html Checks if the current bitset is a subset of another bitset `a`. Returns `true` if every set bit in the current bitset is also set in `a`. Requires both bitsets to have the same size. ```C++ bool is_subset_of(const dynamic_bitset& a) const ``` -------------------------------- ### Resetting All Bits in Boost Dynamic Bitset C++ Source: https://github.com/boostorg/dynamic_bitset/blob/develop/dynamic_bitset.html Clears every bit in the current bitset (sets them to 0). Returns a reference to the current bitset and does not throw exceptions. ```C++ dynamic_bitset& reset() ``` -------------------------------- ### Bitwise AND Assigning Boost Dynamic Bitset C++ Source: https://github.com/boostorg/dynamic_bitset/blob/develop/dynamic_bitset.html Performs a bitwise AND operation between the current bitset and `rhs`, storing the result in the current bitset. Requires both bitsets to have the same size. Returns a reference to the current bitset and does not throw exceptions. ```C++ dynamic_bitset& operator&=(const dynamic_bitset& rhs) ``` -------------------------------- ### Checking for Proper Subset Relationship - Boost dynamic_bitset - C++ Source: https://github.com/boostorg/dynamic_bitset/blob/develop/dynamic_bitset.html Checks if the current bitset is a proper subset of another bitset `a`. Returns `true` if it's a subset and has fewer set bits than `a`. Requires both bitsets to have the same size. ```C++ bool is_proper_subset_of(const dynamic_bitset& a) const ``` -------------------------------- ### Convert dynamic_bitset to String (C++) Source: https://github.com/boostorg/dynamic_bitset/blob/develop/dynamic_bitset.html Copies a string representation of the dynamic_bitset into a provided std::basic_string. '1' represents set bits, '0' represents unset bits. Character position i corresponds to bit position size() - 1 - i. Throws an allocation error if the string operation exhausts memory. ```C++ template void to_string(const dynamic_bitset& b, std::basic_string& s) ``` -------------------------------- ### Read dynamic_bitset from Block Range (C++) Source: https://github.com/boostorg/dynamic_bitset/blob/develop/dynamic_bitset.html Reads blocks from an input iterator range into the bitset. Requires the iterator to be an Input Iterator with value_type matching Block and the input range size <= num_blocks(). ```C++ template void from_block_range(BlockIterator first, BlockIterator last, const dynamic_bitset& b) ``` -------------------------------- ### Right Shift Assigning Boost Dynamic Bitset C++ Source: https://github.com/boostorg/dynamic_bitset/blob/develop/dynamic_bitset.html Shifts the bits in the current bitset to the right by `n` positions, filling new positions with zero. Returns a reference to the current bitset and does not throw exceptions. ```C++ dynamic_bitset& operator>>=(size_type n) ``` -------------------------------- ### Bitwise OR Assigning Boost Dynamic Bitset C++ Source: https://github.com/boostorg/dynamic_bitset/blob/develop/dynamic_bitset.html Performs a bitwise OR operation between the current bitset and `rhs`, storing the result in the current bitset. Requires both bitsets to have the same size. Returns a reference to the current bitset and does not throw exceptions. ```C++ dynamic_bitset& operator|=(const dynamic_bitset& rhs) ``` -------------------------------- ### Setting Range of Bits in Boost Dynamic Bitset C++ Source: https://github.com/boostorg/dynamic_bitset/blob/develop/dynamic_bitset.html Sets or clears a range of bits from index `n` up to `n + len - 1` based on the value of `val`. Requires `n + len` to be less than the size of the bitset. Returns a reference to the current bitset. ```C++ dynamic_bitset& set(size_type n, size_type len, bool val); ``` -------------------------------- ### Left Shift Assigning Boost Dynamic Bitset C++ Source: https://github.com/boostorg/dynamic_bitset/blob/develop/dynamic_bitset.html Shifts the bits in the current bitset to the left by `n` positions, filling new positions with zero. Returns a reference to the current bitset and does not throw exceptions. ```C++ dynamic_bitset& operator<<=(size_type n) ``` -------------------------------- ### Bitwise OR Operator for dynamic_bitset (C++) Source: https://github.com/boostorg/dynamic_bitset/blob/develop/dynamic_bitset.html Performs a bitwise OR operation between two dynamic_bitset objects. Requires both bitsets to have the same size. Returns a new dynamic_bitset representing the result. Throws std::bad_alloc on memory exhaustion. ```C++ dynamic_bitset operator|(const dynamic_bitset& a, const dynamic_bitset& b) ``` -------------------------------- ### Set Difference Assigning Boost Dynamic Bitset C++ Source: https://github.com/boostorg/dynamic_bitset/blob/develop/dynamic_bitset.html Computes the set difference between the current bitset and `rhs`, storing the result in the current bitset. This is equivalent to `(*this)[i] = (*this)[i] && !rhs[i]`. Requires both bitsets to have the same size. Returns a reference to the current bitset and does not throw exceptions. ```C++ dynamic_bitset& operator-=(const dynamic_bitset& rhs) ``` -------------------------------- ### Set Difference Operator for dynamic_bitset (C++) Source: https://github.com/boostorg/dynamic_bitset/blob/develop/dynamic_bitset.html Performs a set difference operation between two dynamic_bitset objects (a - b). Requires both bitsets to have the same size. Returns a new dynamic_bitset representing the result. Throws std::bad_alloc on memory exhaustion. ```C++ dynamic_bitset operator-(const dynamic_bitset& a, const dynamic_bitset& b) ``` -------------------------------- ### Setting Single Bit in Boost Dynamic Bitset C++ Source: https://github.com/boostorg/dynamic_bitset/blob/develop/dynamic_bitset.html Sets or clears the bit at index `n` based on the value of `val`. Requires `n` to be less than the size of the bitset. Returns a reference to the current bitset. ```C++ dynamic_bitset& set(size_type n, bool val = true) ``` -------------------------------- ### Less Than or Equal Comparison (operator<=) - Boost dynamic_bitset - C++ Source: https://github.com/boostorg/dynamic_bitset/blob/develop/dynamic_bitset.html Performs a less than or equal to comparison. Returns `true` if the current bitset is less than or equal to `rhs`. Defined in terms of `operator<` and `operator==`. Requires the `Less Than Comparable` concept. ```C++ bool operator<=(const dynamic_bitset& rhs) const ``` -------------------------------- ### Resizing Boost Dynamic Bitset C++ Source: https://github.com/boostorg/dynamic_bitset/blob/develop/dynamic_bitset.html Changes the size of the bitset to `num_bits`. If the size increases, new bits are set to `value`. If the size decreases, bits beyond `num_bits` are discarded. May throw `std::bad_alloc` if memory is exhausted. ```C++ void resize(size_type num_bits, bool value = false); ``` -------------------------------- ### Bitwise NOT on Boost Dynamic Bitset C++ Source: https://github.com/boostorg/dynamic_bitset/blob/develop/dynamic_bitset.html Returns a new bitset that is a copy of the current bitset with all of its bits flipped (bitwise NOT). May throw `std::bad_alloc` if memory is exhausted. ```C++ dynamic_bitset operator~() const ``` -------------------------------- ### Bitwise XOR Assigning Boost Dynamic Bitset C++ Source: https://github.com/boostorg/dynamic_bitset/blob/develop/dynamic_bitset.html Performs a bitwise XOR operation between the current bitset and `rhs`, storing the result in the current bitset. Requires both bitsets to have the same size. Returns a reference to the current bitset and does not throw exceptions. ```C++ dynamic_bitset& operator^=(const dynamic_bitset& rhs) ``` -------------------------------- ### Accessing Bit (Const) via operator[] - Boost dynamic_bitset - C++ Source: https://github.com/boostorg/dynamic_bitset/blob/develop/dynamic_bitset.html Provides read-only access to bit `n`. Returns the value of bit `n`, equivalent to calling `test(n)`. Requires `n` to be less than the bitset size. ```C++ bool operator[](size_type n) const ``` -------------------------------- ### Clearing Boost Dynamic Bitset C++ Source: https://github.com/boostorg/dynamic_bitset/blob/develop/dynamic_bitset.html Sets the size of the bitset to zero, effectively removing all bits. This operation does not throw exceptions. ```C++ void clear() ``` -------------------------------- ### Appending Block to Boost Dynamic Bitset C++ Source: https://github.com/boostorg/dynamic_bitset/blob/develop/dynamic_bitset.html Appends the bits contained in `value` to the most-significant end of the bitset, increasing its size by `bits_per_block`. May throw `std::bad_alloc` if memory is exhausted. ```C++ void append(Block value); ``` -------------------------------- ### Accessing Bit with Bounds Check - Boost dynamic_bitset - C++ Source: https://github.com/boostorg/dynamic_bitset/blob/develop/dynamic_bitset.html Checks if bit `n` is set, with bounds checking. Returns the value of bit `n`. Throws `std::out_of_range` if `n` is out of bounds. Requires `n` to be less than the bitset size. ```C++ bool at(size_type n) const ``` -------------------------------- ### Bitwise XOR Operator for dynamic_bitset (C++) Source: https://github.com/boostorg/dynamic_bitset/blob/develop/dynamic_bitset.html Performs a bitwise XOR operation between two dynamic_bitset objects. Requires both bitsets to have the same size. Returns a new dynamic_bitset representing the result. Throws std::bad_alloc on memory exhaustion. ```C++ dynamic_bitset operator^(const dynamic_bitset& a, const dynamic_bitset& b) ``` -------------------------------- ### Checking for Intersection - Boost dynamic_bitset - C++ Source: https://github.com/boostorg/dynamic_bitset/blob/develop/dynamic_bitset.html Checks if the current bitset intersects with another bitset `a`. Returns `true` if there is at least one bit set in both bitsets. Requires both bitsets to have the same size. ```C++ bool intersects(const dynamic_bitset& a) const ``` -------------------------------- ### Stream Extraction Operator for dynamic_bitset (C++) Source: https://github.com/boostorg/dynamic_bitset/blob/develop/dynamic_bitset.html Extracts a dynamic_bitset from an input stream. Reads '0' or '1' digits, clearing the bitset and appending corresponding bit values. Extraction stops after n bits (stream.width() or max_size()), EOF/error, or non-digit character. Sets failbit if no characters are extracted. Throws std::bad_alloc on memory exhaustion or std::ios_base::failure on reading problems. ```C++ template std::basic_istream& operator>>(std::basic_istream& is, dynamic_bitset& b) ``` -------------------------------- ### Greater Than or Equal Comparison (operator>=) - Boost dynamic_bitset - C++ Source: https://github.com/boostorg/dynamic_bitset/blob/develop/dynamic_bitset.html Performs a greater than or equal to comparison. Returns `true` if the current bitset is greater than or equal to `rhs`. Defined in terms of `operator>` and `operator==`. Requires the `Less Than Comparable` concept. ```C++ bool operator>=(const dynamic_bitset& rhs) const ``` -------------------------------- ### Resetting Range of Bits in Boost Dynamic Bitset C++ Source: https://github.com/boostorg/dynamic_bitset/blob/develop/dynamic_bitset.html Clears (sets to 0) a range of bits from index `n` up to `n + len - 1`. Requires `n + len` to be less than the size of the bitset. Returns a reference to the current bitset. ```C++ dynamic_bitset& reset(size_type n, size_type len); ``` -------------------------------- ### Resetting Single Bit in Boost Dynamic Bitset C++ Source: https://github.com/boostorg/dynamic_bitset/blob/develop/dynamic_bitset.html Clears (sets to 0) the bit at index `n`. Requires `n` to be less than the size of the bitset. Returns a reference to the current bitset. ```C++ dynamic_bitset& reset(size_type n) ``` -------------------------------- ### Appending Bit to Boost Dynamic Bitset C++ Source: https://github.com/boostorg/dynamic_bitset/blob/develop/dynamic_bitset.html Increases the size of the bitset by one and sets the value of the new most-significant bit to `value`. May throw `std::bad_alloc` if memory is exhausted. ```C++ void push_back(bool value); ``` -------------------------------- ### Greater Than Comparison (operator>) - Boost dynamic_bitset - C++ Source: https://github.com/boostorg/dynamic_bitset/blob/develop/dynamic_bitset.html Performs a greater than comparison. Returns `true` if the current bitset is greater than `rhs`. Defined in terms of `operator<` and `operator==`. Requires the `Less Than Comparable` concept. ```C++ bool operator>(const dynamic_bitset& rhs) const ``` -------------------------------- ### Destroying dynamic_bitset: Destructor Source: https://github.com/boostorg/dynamic_bitset/blob/develop/dynamic_bitset.html Releases all memory associated with the dynamic_bitset object and destroys the object itself. ```C++ ~dynamic_bitset() ``` -------------------------------- ### Converting Bitset to unsigned long - Boost dynamic_bitset - C++ Source: https://github.com/boostorg/dynamic_bitset/blob/develop/dynamic_bitset.html Converts the bitset to an `unsigned long`. Returns the numeric value represented by the bits. Throws `std::overflow_error` if the value exceeds the capacity of `unsigned long`. ```C++ unsigned long to_ulong() const ``` -------------------------------- ### Removing Last Bit from Boost Dynamic Bitset C++ Source: https://github.com/boostorg/dynamic_bitset/blob/develop/dynamic_bitset.html Decreases the size of the bitset by one, removing the most significant bit. Requires the bitset not to be empty. This operation does not throw exceptions. ```C++ void pop_back(); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.