public member function
<bitset>

std::bitset::reset

all bits (1)
bitset& reset();
single bit (2)
bitset& reset (size_t pos);
all bits (1)
bitset& reset() noexcept;
single bit (2)
bitset& reset (size_t pos);
Reset bits
Resets bits to zero:
(1) all bits
Resets (to zero) all bits in the bitset.
(2) single bit
Resets (to zero) the bit at position pos.

Parameters

pos
Order position of the bit whose value is modified.
Order positions are counted from the rightmost bit, which is order position 0.
If pos is equal or greater than the bitset size, an out_of_range exception is thrown.
size_t is an unsigned integral type.

Return value

*this

Example

1
2
3
4
5
6
7
8
9
10
11
12
13
14
// bitset::reset
#include <iostream>       // std::cout
#include <string>         // std::string
#include <bitset>         // std::bitset

int main ()
{
  std::bitset<4> foo (std::string("1011"));

  std::cout << foo.reset(1) << '\n';    // 1001
  std::cout << foo.reset() << '\n';     // 0000

  return 0;
}

Output:

1001
0000


Data races

Both the bitset and its bits are modified.

Exception safety

For (1): it never throws exceptions (no-throw guarantee).
For (2): in case of exception, the object is in a valid state (basic guarantee).
If pos is equal or greater than the bitset size, the function throws an out_of_range exception.

See also