Namespaces
Variants

Standard library header <bit> (C++20)

From cppreference.net
Standard library headers

このヘッダは numeric ライブラリの一部です。

(C++20)
スカラ型のエンディアンを示す
(列挙型)

関数

(C++20)
ある型のオブジェクト表現を別の型として再解釈する
(関数テンプレート)
(C++23)
指定された整数値のバイト順序を反転する
(関数テンプレート)
数値が 2 の整数乗かどうかをチェックする
(関数テンプレート)
(C++20)
指定された値以上の最小の 2 の整数乗を求める
(関数テンプレート)
(C++20)
指定された値以下の最大の 2 の整数乗を求める
(関数テンプレート)
(C++20)
指定された値を表現するために必要な最小ビット数を求める
(関数テンプレート)
(C++20)
ビット単位の左回転の結果を計算する
(関数テンプレート)
(C++20)
ビット単位の右回転の結果を計算する
(関数テンプレート)
最上位ビットから始まる連続する 0 ビットの数を数える
(関数テンプレート)
(C++20)
最上位ビットから始まる連続する 1 ビットの数を数える
(関数テンプレート)
最下位ビットから始まる連続する 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 = /* 説明を参照 */
  };
}