Standard library header <bit> (C++20)
From zh.cppreference.net
C++
Standard library headers
此头文件是 数值 库的组成部分。
类型 |
|
|
(C++20)
|
指示标量类型的字节序
(枚举) |
函数 | |
(C++20) |
将一个类型的对象表示重新解释为另一种类型 (函数模板) |
(C++23) |
反转给定整数值中的字节 (函数模板) |
(C++20) |
检查一个数是否为2 (函数模板) |
(C++20) |
找到不小于给定值的最小2的整数次幂 (函数模板) |
(C++20) |
找到不大于给定值的最大2的整数次幂 (函数模板) |
(C++20) |
找到表示给定值所需的最小位数 (函数模板) |
(C++29) |
左移而不产生未定义行为 (函数模板) |
(C++29) |
右移而不产生未定义行为 (函数模板) |
(C++20) |
计算按位左旋转的结果 (函数模板) |
(C++20) |
计算按位右旋转的结果 (函数模板) |
(C++20) |
计数连续的0位的数量,从最高有效位开始 (函数模板) |
(C++20) |
计数连续的1位的数量,从最高有效位开始 (函数模板) |
(C++20) |
计数连续的0位的数量,从最低有效位开始 (函数模板) |
(C++20) |
计数连续的1位的数量,从最低有效位开始 (函数模板) |
(C++20) |
计数无符号整数中1位的数量 (函数模板) |
(C++29) |
反转整数中的位 (函数模板) |
(C++29) |
重复/广播指定长度的位模式 (函数模板) |
(C++29) |
使用掩码压缩操作数的位 (PEXT) (函数模板) |
(C++29) |
使用掩码展开操作数的位 (PDEP) (函数模板) |
概要
namespace std {
// bit_cast
template<class To, class From>
constexpr To bit_cast(const From& from) noexcept;
// byteswap
template <class T>
constexpr T byteswap(T value) noexcept;
// integral powers of 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;
// shifting
template<class T, class S>
constexpr T shl(T x, S s) noexcept;
template<class T, class S>
constexpr T shr(T x, S s) noexcept;
// rotating
template<class T>
constexpr T rotl(T x, int s) noexcept;
template<class T>
constexpr T rotr(T x, int s) noexcept;
// counting
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;
// permutation
template<class T>
constexpr T bit_reverse(T x) noexcept;
template<class T>
constexpr T bit_repeat(T x, int l);
template<class T>
constexpr T bit_compress(T x, T m) noexcept;
template<class T>
constexpr T bit_expand(T x, T m) noexcept;
// endian
enum class endian {
little = /* see description */,
big = /* see description */,
native = /* see description */
};
}