标准库标头 <bit>
来自cppreference.com
此头文件是数值库的一部分。
类型 | |
(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 {
// 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;
// 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 = /* 见描述 */
};
}