constexpr index_type extent(rank_type i) const noexcept;
概要
多次元配列サイズのうちi
番目次元の要素数を取得する。
事前条件
i < rank()
戻り値
i
番目次元の要素数。
例外
投げない
例
#include <cassert>
#include <mdspan>
int main()
{
using Ext3x4 = std::extents<size_t, 3, 4>;
static_assert(Ext3x4::static_extent(0) == 3);
static_assert(Ext3x4::static_extent(1) == 4);
Ext3x4 ext1;
assert(ext1.extent(0) == 3);
assert(ext1.extent(1) == 4);
using Ext3xN = std::extents<size_t, 3, std::dynamic_extent>;
static_assert(Ext3xN::static_extent(0) == 3);
static_assert(Ext3xN::static_extent(1) == std::dynamic_extent);
Ext3xN ext2{10};
assert(ext2.extent(0) == 3);
assert(ext2.extent(1) == 10);
}
20
#include <cassert>
#include <mdspan>
int main()
{
using Ext3x4 = std::extents<size_t, 3, 4>;
static_assert(Ext3x4::static_extent(0) == 3);
static_assert(Ext3x4::static_extent(1) == 4);
Ext3x4 ext1;
assert(ext1.extent(0) == 3);
assert(ext1.extent(1) == 4);
using Ext3xN = std::extents<size_t, 3, std::dynamic_extent>;
static_assert(Ext3xN::static_extent(0) == 3);
static_assert(Ext3xN::static_extent(1) == std::dynamic_extent);
Ext3xN ext2{10};
assert(ext2.extent(0) == 3);
assert(ext2.extent(1) == 10);
出力
バージョン
言語
- C++23
処理系
- Clang: ??
- GCC: ??
- ICC: ??
- Visual C++: ??