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

履歴 編集

function
<mdspan>

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

[[nodiscard]] constexpr bool empty() const noexcept;

概要

多次元インデクス空間がサイズ0か否かを取得する。

戻り値

多次元インデクス空間extents()のサイズが0ならばtrueを返す。そうでなければfalseを返す。

例外

投げない

#include <cassert>
#include <mdspan>

using Matrix = std::mdspan<double, std::dextents<size_t, 2>>;

int main()
{
  double arr[] = {1, 2, 3, 4, 5, 6};

  Matrix mat0{arr, 0, 0};
  assert(mat0.empty());

  Matrix mat1{arr, 2, 3};
  assert(not mat1.empty());
}

出力

バージョン

言語

  • C++23

処理系

関連項目

参照