Standard library header <bit> (C++20)
From cppreference.net
此头文件是 数值 库的组成部分。
类型 |
|
|
(C++20)
|
指示标量类型的字节序
(枚举) |
函数 |
|
|
(C++20)
|
将一种类型的对象表示重新解释为另一种类型
(函数模板) |
|
(C++23)
|
反转给定整数值中的字节顺序
(函数模板) |
|
(C++20)
|
检查一个数是否为
2
的整数次幂
(函数模板) |
|
(C++20)
|
查找不小于给定值的最小
2
的整数次幂
(函数模板) |
|
(C++20)
|
查找不大于给定值的最大
2
的整数次幂
(函数模板) |
|
(C++20)
|
查找表示给定值所需的最小位数
(函数模板) |
|
(C++20)
|
计算按位左旋转的结果
(函数模板) |
|
(C++20)
|
计算按位右旋转的结果
(函数模板) |
|
(C++20)
|
从最高有效位开始统计连续
0
位的数量
(函数模板) |
|
(C++20)
|
从最高有效位开始统计连续
1
位的数量
(函数模板) |
|
(C++20)
|
从最低有效位开始统计连续
0
位的数量
(函数模板) |
|
(C++20)
|
从最低有效位开始统计连续
1
位的数量
(函数模板) |
|
(C++20)
|
统计无符号整数中
1
位的数量
(函数模板) |
概要
namespace std { // 位转换 template<class To, class From> constexpr To bit_cast(const From& from) noexcept; // 字节交换 template <class T> constexpr T byteswap(T value) noexcept; // 整数的2次幂运算 template<class T> constexpr bool has_single_bit(T x) noexcept; template<class T> constexpr T bit_ceil(T x); template<class T> constexpr T bit_floor(T x) noexcept; template<class T> constexpr int bit_width(T x) noexcept; // 循环移位 template<class T> constexpr T rotl(T x, int s) noexcept; template<class T> constexpr T rotr(T x, int s) noexcept; // 位计数 template<class T> constexpr int countl_zero(T x) noexcept; template<class T> constexpr int countl_one(T x) noexcept; template<class T> constexpr int countr_zero(T x) noexcept; template<class T> constexpr int countr_one(T x) noexcept; template<class T> constexpr int popcount(T x) noexcept; // 字节序 enum class endian { little = /* 详见说明 */, big = /* 详见说明 */, native = /* 详见说明 */ }; }