标准库头文件 <bit> (C++20)
来自 cppreference.cn
此头文件是 numeric 库的一部分。
类型 | |
(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; // 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; // 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; // endian enum class endian { little = /* see description */, big = /* see description */, native = /* see description */ }; }