std::bitset::reset
STD::位集::重置
bitset | (1) | |
---|---|---|
bitset<N>& reset( size_t pos | (2) | |
将位设置为false
...
1%29将所有位设置为false
2%29设置位在位置pos
到false
...
参数
pos | - | the position of the bit to set |
---|
返回值
*this
...
例外
1%29
(none) | (until C++11) |
---|---|
noexcept specification: noexcept | (since C++11) |
2%29投std::out_of_range
如果pos
不对应于位集中的有效位置。
例
二次
#include <iostream>
#include <bitset>
int main()
{
std::bitset<8> b(42
std::cout << "Bitset is " << b << '\n';
b.reset(1
std::cout << "After b.reset(1): " << b << '\n';
b.reset(
std::cout << "After b.reset(): " << b << '\n';
}
二次
产出:
二次
Bitset is 00101010
After b.reset(1): 00101000
After b.reset(): 00000000
二次
另见
set | sets bits to true or given value (public member function) |
---|---|
flip | toggles the values of bits (public member function) |
© cppreference.com
在CreativeCommonsAttribution下授权-ShareAlike未移植许可v3.0。