命名空间
变体
操作

标准库头文件 <bit> (C++20)

来自 cppreference.cn
< cpp‎ | 头文件
 
 
标准库头文件
通用工具
<any> (C++17)
<bitset>
<bit> (C++20)
<charconv> (C++17)
<expected> (C++23)
<format> (C++20)
<functional>
<optional> (C++17)
<tuple> (C++11)
<typeindex> (C++11)
<utility>
<variant> (C++17)
容器
<array> (C++11)
<deque>
<flat_map> (C++23)
<flat_set> (C++23)
<forward_list> (C++11)
<hive> (C++26)
<inplace_vector> (C++26)   
<list>
<map>
<mdspan> (C++23)
<queue>
<set>
<span> (C++20)
<stack>
<unordered_map> (C++11)
<unordered_set> (C++11)
<vector>
迭代器
<iterator>
范围
<generator> (C++23)
<ranges> (C++20)
算法
<algorithm>
<numeric>
字符串
<cctype>
<cstring>
<cuchar> (C++11)
<cwchar>
<cwctype>
<string_view> (C++17)
<string>
文本处理
<clocale>
<codecvt> (C++11/17/26*)
<locale>
<regex> (C++11)
<text_encoding> (C++26)   
数值
<cfenv> (C++11)
<cmath>
<complex>
<linalg> (C++26)
<numbers> (C++20)
<random> (C++11)
<simd> (C++26)
<valarray>
时间
<chrono> (C++11)
<ctime>
C 兼容性
<ccomplex> (C++11/17/20*)
<ciso646> (until C++20)
<cstdalign> (C++11/17/20*)
<cstdbool> (C++11/17/20*)
<ctgmath> (C++11/17/20*)
 

此头文件是数值库的一部分。

类型

(C++20)
指示标量类型的字节序
(枚举) [编辑]

函数

(C++20)
将一种类型的对象表示重新解释为另一种类型
(函数模板) [编辑]
(C++23)
反转给定整数值中的字节
(函数模板) [编辑]
检查数字是否为 2 的整数幂
(函数模板) [编辑]
(C++20)
查找不小于给定值的最小 2 的整数幂
(函数模板) [编辑]
(C++20)
查找不大于给定值的最大 2 的整数幂
(函数模板) [编辑]
(C++20)
查找表示给定值所需的最小位数
(函数模板) [编辑]
(C++20)
计算按位左旋转的结果
(函数模板) [编辑]
(C++20)
计算按位右旋转的结果
(函数模板) [编辑]
从最高有效位开始,计数连续 0 位的数量
(函数模板) [编辑]
从最高有效位开始,计数连续 1 位的数量
(函数模板) [编辑]
从最低有效位开始,计数连续 0 位的数量
(函数模板) [编辑]
从最低有效位开始,计数连续 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 */
  };
}