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::simd::bit_width - cpprefjp C++日本語リファレンス

  1. リファレンス
  2. simd
  3. bit_width

最終更新日時: 2026年07月31日 23時18分35秒 (JST)
Akira Takahashi が更新

履歴 編集

function template
<simd>

std::simd::bit_width(C++26)

namespace std::simd {
  template<simd-vec-type V>
  constexpr rebind_t<make_signed_t<typename V::value_type>, V>
    bit_width(const V& v) noexcept; // C++26
}

概要

符号なし整数要素をもつbasic_vecの各要素に対して、std::bit_widthを要素ごとに適用し、各要素を表現するのに必要なビット数を求める。

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

  • V::value_typeが符号なし整数型であること

戻り値

i番目の要素がstd::bit_width(v[i])で初期化されたbasic_vecオブジェクトを返す。要素型はV::value_typeを符号付き整数型にしたものである。

例外

投げない

例

#include <simd>
#include <print>
#include <array>
#include <cstdint>

namespace simd = std::simd;

int main()
{
  std::array data = {0b000u, 0b001u, 0b100u, 0b111u};
  simd::vec<std::uint32_t, 4> v {[&](int i) { return data[i]; }};

  auto r = simd::bit_width(v);

  for (int i = 0; i < v.size(); ++i) {
    std::println("{:016b} -> {}", v[i], r[i]);
  }
}

出力

0000000000000000 -> 0
0000000000000001 -> 1
0000000000000100 -> 3
0000000000000111 -> 3

バージョン

言語

  • C++26

処理系

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

関連項目

  • std::bit_width

参照

  • P1928R15 std::simd — merge data-parallel types from the Parallelism TS 2
    • C++26でstd::simdライブラリが追加された
  • P2933R4 Extend <bit> header function with overloads for std::simd
    • C++26で<bit>ヘッダの関数にstd::simd向けのオーバーロードが追加された
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.