最終更新日時(UTC):
が更新

履歴 編集

function
<mdspan>

std::mdspan::extent(C++23)

constexpr index_type extent(rank_type r) const noexcept;

概要

指定次元の要素数を取得する。

戻り値

extents().extent(r)

例外

投げない

#include <cassert>
#include <mdspan>

int main()
{
  int arr[] = {1, 2, 3, 4, 5, 6};
  // 動的要素数 2x3 の2次元配列ビュー
  std::mdspan<int, std::dextents<size_t, 2>> mat{arr, 2, 3};

  static_assert(mat.static_extent(1) == std::dynamic_extent);
  assert(mat.extent(1) == 3);
}

出力

バージョン

言語

  • C++23

処理系

関連項目

参照