GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • cpprefjp - C++日本語リファレンス
  • GitHub Project

This view

  • Original page
  • New address

GeezerVison is showing cpprefjp.github.io — std::bit_reverse - cpprefjp C++日本語リファレンス

  1. リファレンス
  2. bit
  3. bit_reverse

最終更新日時: 2026年10月15日 11時31分14秒 (JST)
Akira Takahashi が更新

履歴 編集

function template
<bit>

std::bit_reverse(C++29)

namespace std {
  template <class T>
  constexpr T bit_reverse(T x) noexcept; // C++29
}

概要

値xのビット列の並びを反転する。

最下位ビットと最上位ビットを入れ替えるように、すべてのビットを逆順に並べ替える。

テンプレートパラメータ制約

  • 型Tが符号なし整数型であること

戻り値

Tのビット数をN(std::numeric_limits<T>::digits)とする。xの第nビット(0以上N未満)を第N - 1 - nビットへ移した値を返す。

例外

投げない

備考

  • bit_reverse(bit_reverse(x))はxに等しい。
  • この関数は、ハードウェア機能として提供されている場合がある。

例

#include <bit>
#include <cstdint>
#include <print>

int main()
{
  std::uint16_t x = 0b0000'0000'0000'0001;

  std::uint16_t r = std::bit_reverse(x);

  std::println("{:016b}", r);
}

出力

1000000000000000

バージョン

言語

  • C++29

処理系

  • Clang: 22 ❌
  • GCC: 17 ✅
  • Visual C++: 2026 Update 2 ❌

関連項目

  • std::bit_repeat
  • std::byteswap
  • std::rotl

参照

  • P3104R6 Bit permutations
    • C++29で追加された
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.