std::bitset
来自cppreference.com
| 定义于头文件 <bitset>
|
||
| template< std::size_t N > class bitset; |
||
类模板 bitset 表示一个 N 位的固定大小序列。可以用标准逻辑运算符操作bitset,并将它与字符串和整数相互转换。
bitset 满足可复制构造 (CopyConstructible) 及可复制赋值 (CopyAssignable) 的要求。
模板形参
| N | - | 要为 bitset 分配存储的位数
|
成员类型
| 表示到一个位的引用的代理类 (类) |
成员函数
| 构造 bitset (公开成员函数) | |
| (C++20 中移除) |
比较其内容 (公开成员函数) |
元素访问 | |
| 访问指定的位 (公开成员函数) | |
| 访问特定位 (公开成员函数) | |
| (C++11) |
检查是否所有、任一或无位被设为 true (公开成员函数) |
| 返回设置为 true 的位的数量 (公开成员函数) | |
容量 | |
| 返回位集保有的位数 (公开成员函数) | |
修改器 | |
| 进行二进制与、或、异或及非 (公开成员函数) | |
| 进行二进制左移和右移 (公开成员函数) | |
| 将位置为 true 或者提供的值 (公开成员函数) | |
| 将位置为 false (公开成员函数) | |
| 翻转位的值 (公开成员函数) | |
转换 | |
| 返回数据的字符串表示 (公开成员函数) | |
| 返回数据的 unsigned long 整数表示 (公开成员函数) | |
| (C++11) |
返回数据的 unsigned long long 整数表示 (公开成员函数) |
非成员函数
| 在 bitset 上执行二元逻辑操作 (函数) | |
| 执行 bitset 的流输入和输出 (函数) |
辅助类
| (C++11) |
std::bitset 的散列支持 (类模板特化) |
注解
若在编译时 bitset 的大小未知,则可使用 std::vector<bool> 或 boost::dynamic_bitset 。