---
name: "std::tr2::dynamic_bitset"
section: "3"
platform: "linux"
package: "gcc"
version: "16.2.1+r23+gd564253eb6c8-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/std::tr2::dynamic_bitset"
---

# std::tr2::dynamic\_bitset(3)

The dynamic\_bitset class represents a sequence of bits.

## NAME

std::tr2::dynamic\_bitset\< \_WordT, \_Alloc \> - The dynamic\_bitset class represents a sequence of bits.

## SYNOPSIS

\#include \<dynamic\_bitset\>

Inherits **std::tr2::\_\_dynamic\_bitset\_base\< \_WordT, \_Alloc \>**.

### Classes

class **reference**\

### Public Types

typedef \_\_dynamic\_bitset\_base\< \_WordT, \_Alloc \> **\_Base**\
 typedef \_Alloc **allocator\_type**\
 typedef \_WordT **block\_type**\
 typedef bool **const\_reference**\
 typedef size\_t **size\_type**\

### Public Member Functions

**dynamic\_bitset** ()=default\
 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.

**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

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

class std::tr2::dynamic\_bitset\< \_WordT, \_Alloc \>"The dynamic\_bitset class represents a sequence of bits.

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

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

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

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

```
#include <dynamic_bitset>
#include <iostream>
#include <sstream>
using namespace std;
int main()
{
    long         a = 'a';
    dynamic_bitset<> b(a);
    cout << "b('a') is " << b << endl;
    ostringstream s;
    s << b;
    string  str = s.str();
    cout << "index 3 in the string is " << str[3] << " but\n"
         << "index 3 in the bitset is " << b[3] << endl;
}
```

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

Extra confusion can result due to the fact that the storage for \_\_dynamic\_bitset\_base *is* a vector, and is indexed as such. This is carefully encapsulated.

## Constructor & Destructor Documentation

### template\<typename \_WordT = unsigned long long, typename \_Alloc = std::allocator\<\_WordT\>\> std::tr2::dynamic\_bitset\< \_WordT, \_Alloc \>::dynamic\_bitset () \[default\]

All bits set to zero.

Referenced by **dynamic\_bitset()**, **dynamic\_bitset()**, **operator&=()**, **operator&=()**, **operator-=()**, **operator\<\<()**, **operator\<\<=()**, **operator=()**, **operator=()**, **operator\>\>()**, **operator^=()**, **operator\|=()**, **operator~()**, and **swap()**.

### 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.

### 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).

### template\<typename \_WordT = unsigned long long, typename \_Alloc = std::allocator\<\_WordT\>\> template\<typename \_CharT, typename \_Traits, typename \_Alloc1\> std::tr2::dynamic\_bitset\< \_WordT, \_Alloc \>::dynamic\_bitset (const std::basic\_string\< \_CharT, \_Traits, \_Alloc1 \> & \_\_str, typename basic\_string\< \_CharT, \_Traits, \_Alloc1 \>::size\_type \_\_pos = 0, typename basic\_string\< \_CharT, \_Traits, \_Alloc1 \>::size\_type \_\_n = std::basic\_string\<\_CharT, \_Traits, \_Alloc1\>::npos, \_CharT \_\_zero = \_CharT('0'), \_CharT \_\_one = \_CharT('1'), const allocator\_type & \_\_alloc = allocator\_type()) \[inline\], \[explicit\]

Use a subset of a string.

**Parameters**

*\_\_str* A string of '0' and '1' characters. \
 *\_\_pos* Index of the first character in \_\_str to use. \
 *\_\_n* The number of characters to copy. \
 *\_\_zero* The character to use for unset bits. \
 *\_\_one* The character to use for set bits. \
 *\_\_alloc* An allocator.

**Exceptions**

**std::out\_of\_range If** \_\_pos **is bigger the size of** \_\_str**.** \
 **std::invalid\_argument If a character appears in the string which is neither '0' nor '1'.**

**References std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::npos, and std::basic\_string\< \_CharT, \_Traits, \_Alloc \>::size().**

### template\<typename \_WordT = unsigned long long, typename \_Alloc = std::allocator\<\_WordT\>\> std::tr2::dynamic\_bitset\< \_WordT, \_Alloc \>::dynamic\_bitset (const char \* \_\_str, const allocator\_type & \_\_alloc = allocator\_type()) \[inline\], \[explicit\]

**Construct from a string.**

**Parameters**

*\_\_str* **A string of '0' and '1' characters.** \
 *\_\_alloc* **An allocator.**

**Exceptions**

**std::invalid\_argument If a character appears in the string which is neither '0' nor '1'.**

### template\<typename \_WordT = unsigned long long, typename \_Alloc = std::allocator\<\_WordT\>\> std::tr2::dynamic\_bitset\< \_WordT, \_Alloc \>::dynamic\_bitset (const dynamic\_bitset\< \_WordT, \_Alloc \> & ) \[default\]

**Copy constructor.**

**References dynamic\_bitset().**

### 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.**

**References dynamic\_bitset(), and std::move().**

## Member Function Documentation

### template\<typename \_WordT = unsigned long long, typename \_Alloc = std::allocator\<\_WordT\>\> bool std::tr2::dynamic\_bitset\< \_WordT, \_Alloc \>::all () const \[inline\]

**Tests whether all the bits are on.**

**Returns**

**True if all the bits are set.**

### template\<typename \_WordT = unsigned long long, typename \_Alloc = std::allocator\<\_WordT\>\> bool std::tr2::dynamic\_bitset\< \_WordT, \_Alloc \>::any () const \[inline\]

**Tests whether any of the bits are on.**

**Returns**

**True if at least one bit is set.**

### 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.**

**References append().**

### 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.**

**Referenced by append().**

### template\<typename \_WordT = unsigned long long, typename \_Alloc = std::allocator\<\_WordT\>\> void std::tr2::dynamic\_bitset\< \_WordT, \_Alloc \>::clear () \[inline\]

**Clear the bitset.**

### 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.**

### 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.**

### template\<typename \_WordT = unsigned long long, typename \_Alloc = std::allocator\<\_WordT\>\> size\_type std::tr2::dynamic\_bitset\< \_WordT, \_Alloc \>::find\_first () const \[inline\]

**Finds the index of the first "on" bit.**

**Returns**

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

**See also**

**find\_next**

### template\<typename \_WordT = unsigned long long, typename \_Alloc = std::allocator\<\_WordT\>\> size\_type std::tr2::dynamic\_bitset\< \_WordT, \_Alloc \>::find\_next (size\_t \_\_prev) const \[inline\]

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

**Returns**

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

**Parameters**

*\_\_prev* **Where to start searching.**

**See also**

**find\_first**

### 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.**

**Referenced by operator~().**

### template\<typename \_WordT = unsigned long long, typename \_Alloc = std::allocator\<\_WordT\>\> dynamic\_bitset & std::tr2::dynamic\_bitset\< \_WordT, \_Alloc \>::flip (size\_type \_\_pos) \[inline\]

**Toggles a given bit to its opposite value.**

**Parameters**

*\_\_pos* **The index of the bit.**

**Exceptions**

**std::out\_of\_range If** *\_\_pos* **is bigger the size of the set.**

### 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.**

**Referenced by operator=().**

### 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.**

**References std::numeric\_limits\< \_Tp \>::max().**

### template\<typename \_WordT = unsigned long long, typename \_Alloc = std::allocator\<\_WordT\>\> bool std::tr2::dynamic\_bitset\< \_WordT, \_Alloc \>::none () const \[inline\]

**Tests whether any of the bits are on.**

**Returns**

**True if none of the bits are set.**

### 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.**

### 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().**

### 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().**

### 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().**

### 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.**

**References dynamic\_bitset().**

### 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().**

### template\<typename \_WordT = unsigned long long, typename \_Alloc = std::allocator\<\_WordT\>\> dynamic\_bitset & std::tr2::dynamic\_bitset\< \_WordT, \_Alloc \>::operator= (const dynamic\_bitset\< \_WordT, \_Alloc \> & ) \[default\]

**Copy assignment operator.**

**References dynamic\_bitset().**

### 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.**

**References dynamic\_bitset(), and get\_allocator().**

### 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.**

**References dynamic\_bitset().**

### 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.**

### template\<typename \_WordT = unsigned long long, typename \_Alloc = std::allocator\<\_WordT\>\> reference std::tr2::dynamic\_bitset\< \_WordT, \_Alloc \>::operator\[\] (size\_type \_\_pos) \[inline\]

**Array-indexing support.**

**Parameters**

*\_\_pos* **Index into the dynamic\_bitset.**

**Returns**

**A bool for a 'const dynamic\_bitset'. For non-const bitsets, an instance of the reference proxy class.**

**Note**

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

### template\<typename \_WordT = unsigned long long, typename \_Alloc = std::allocator\<\_WordT\>\> const\_reference std::tr2::dynamic\_bitset\< \_WordT, \_Alloc \>::operator\[\] (size\_type \_\_pos) const \[inline\]

**Array-indexing support.**

**Parameters**

*\_\_pos* **Index into the dynamic\_bitset.**

**Returns**

**A bool for a 'const dynamic\_bitset'. For non-const bitsets, an instance of the reference proxy class.**

**Note**

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

### 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().**

### 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().**

### 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().**

**References dynamic\_bitset(), and flip().**

### 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.**

**References size().**

### 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.**

### template\<typename \_WordT = unsigned long long, typename \_Alloc = std::allocator\<\_WordT\>\> dynamic\_bitset & std::tr2::dynamic\_bitset\< \_WordT, \_Alloc \>::reset (size\_type \_\_pos) \[inline\]

**Sets a given bit to false.**

**Parameters**

*\_\_pos* **The index of the bit.**

**Exceptions**

**std::out\_of\_range If** *\_\_pos* **is bigger the size of the set.**

**Same as writing** set(\_\_pos, false)**.**

### 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.**

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

### 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.**

### template\<typename \_WordT = unsigned long long, typename \_Alloc = std::allocator\<\_WordT\>\> dynamic\_bitset & std::tr2::dynamic\_bitset\< \_WordT, \_Alloc \>::set (size\_type \_\_pos, bool \_\_val = true) \[inline\]

**Sets a given bit to a particular value.**

**Parameters**

*\_\_pos* **The index of the bit.** \
 *\_\_val* **Either true or false, defaults to true.**

**Exceptions**

**std::out\_of\_range If** *\_\_pos* **is bigger the size of the set.**

### 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.**

**Referenced by std::tr2::operator\>\>(), and push\_back().**

### 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.**

**References dynamic\_bitset().**

### template\<typename \_WordT = unsigned long long, typename \_Alloc = std::allocator\<\_WordT\>\> bool std::tr2::dynamic\_bitset\< \_WordT, \_Alloc \>::test (size\_type \_\_pos) const \[inline\]

**Tests the value of a bit.**

**Parameters**

*\_\_pos* **The index of a bit.**

**Returns**

**The value at** *\_\_pos***.**

**Exceptions**

**std::out\_of\_range If** *\_\_pos* **is bigger the size of the set.**

### template\<typename \_WordT = unsigned long long, typename \_Alloc = std::allocator\<\_WordT\>\> template\<typename \_CharT = char, typename \_Traits = std::char\_traits\<\_CharT\>, typename \_Alloc1 = std::allocator\<\_CharT\>\> std::basic\_string\< \_CharT, \_Traits, \_Alloc1 \> std::tr2::dynamic\_bitset\< \_WordT, \_Alloc \>::to\_string (\_CharT \_\_zero = \_CharT('0'), \_CharT \_\_one = \_CharT('1')) const \[inline\]

**Returns a character interpretation of the dynamic\_bitset.**

**Returns**

**The string equivalent of the bits.**

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

### template\<typename \_WordT = unsigned long long, typename \_Alloc = std::allocator\<\_WordT\>\> unsigned long long std::tr2::dynamic\_bitset\< \_WordT, \_Alloc \>::to\_ullong () const \[inline\]

**Returns a numerical interpretation of the dynamic\_bitset.**

**Returns**

**The integral equivalent of the bits.**

**Exceptions**

**std::overflow\_error If there are too many bits to be represented in an** unsigned long**.**

### template\<typename \_WordT = unsigned long long, typename \_Alloc = std::allocator\<\_WordT\>\> unsigned long std::tr2::dynamic\_bitset\< \_WordT, \_Alloc \>::to\_ulong () const \[inline\]

**Returns a numerical interpretation of the dynamic\_bitset.**

**Returns**

**The integral equivalent of the bits.**

**Exceptions**

**std::overflow\_error If there are too many bits to be represented in an** unsigned long**.**

## Author

**Generated automatically by Doxygen for libstdc++ from the source code.**
