定义于头文件 <bitset>
template< std::size_t N > |
类模板 bitset
表示一个 N
位的固定大小序列。可以用标准逻辑运算符操作位集,并将它与字符串和整数相互转换。
bitset
满足可复制构造 (CopyConstructible) 及可复制赋值 (CopyAssignable) 的要求。
模板形参
N | - | 要为 bitset 分配存储的位数 |
成员类型
reference |
表示到一个位的引用的代理类 (类) |
std::bitset<N>::reference
class reference; |
std::bitset 类包含 std::bitset::reference 作为可公开访问的嵌套类。此类用作允许用户与 bitset 的单个位交互的代理对象,因为标准 C++ 类型(如引用和指针)没有内建指定单个位的足够精度。
std::bitset::reference 的基本用途是提供能从 operator[]
返回的左值。
任何通过 std::bitset::reference 对 bitset 的读或写潜在地读或写整个底层 bitset 。
成员函数
(构造函数) |
构造引用。只对 std::bitset 自身可访问 (私有成员函数) |
(析构函数) |
销毁引用 (公开成员函数) |
operator= |
赋值 bool 给被引用位 (公开成员函数) |
operator bool |
返回被引用位 (公开成员函数) |
operator~ |
返回翻转的被引用位 (公开成员函数) |
flip |
翻转被引用位 (公开成员函数) |
std::bitset<N>::reference::~reference
~reference(); |
销毁引用。
std::bitset<N>::reference::operator=
reference& operator=( bool x ); |
(1) | (C++11 前) |
reference& operator=( bool x ) noexcept; |
(C++11 起) | |
reference& operator=( const reference& x ); |
(2) | (C++11 前) |
reference& operator=( const reference& x ) noexcept; |
(C++11 起) |
赋值给被引用位。
参数
x | - | 要赋值的值 |
返回值
*this
std::bitset<N>::reference::operator bool
operator bool() const; |
(C++11 前) | |
operator bool() const noexcept; |
(C++11 起) |
返回被引用位的值。
参数
(无)
返回值
被引用位。
std::bitset<N>::reference::operator~
bool operator~() const; |
(C++11 前) | |
bool operator~() const noexcept; |
(C++11 起) |
返回被引用位的翻转。
参数
(无)
返回值
被引用位的翻转。
std::bitset<N>::reference::flip
reference& flip(); |
(C++11 前) | |
reference& flip() noexcept; |
(C++11 起) |
翻转被引用位。
参数
(无)
返回值
*this