A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://cplusplus.com/reference/bitset/bitset/reset/ below:

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:


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
bitset::set
Set bits (public member function)
bitset::flip
Flip bits (public member function)

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4