template<class... Indices>
constexpr index_type operator()(Indices... i) const noexcept;
概要
多次元インデクス値i...
に対応する要素位置を求める。
テンプレートパラメータ制約
sizeof...(Indices) == extents_type::rank()
がtrue
、かつ(is_convertible_v<Indices, index_type> && ...)
がtrue
、かつ(is_nothrow_constructible_v<index_type, Indices> && ...)
がtrue
であること。
事前条件
多次元インデクス値extents_type::index-cast(i)
は、多次元配列サイズextents_
における有効なインデクスであること。
戻り値
説明用のパラメータパックP
において、is_same_v<index_sequence_for<Indices...>, index_sequence<P...>>
がtrue
となるとき、以下と等価。
return ((static_cast<index_type>(Indices...) * stride(P)) + ... + 0);
例外
投げない
例
#include <cassert>
#include <array>
#include <mdspan>
int main()
{
using Ext3D = std::dextents<size_t, 3>;
using Mapping = std::layout_stride::mapping<Ext3D>;
std::array strides{6, 1, 3};
Mapping map{Ext3D{4, 3, 2}, strides};
// map(i,j,k):
// i= 0 | 1 | 2 | 3
// ------+-------+-------+-------
// j/k ->
// | 0 3 | 6 9 | 12 15 | 18 21
// V 1 4 | 7 10 | 13 16 | 19 22
// 2 5 | 8 11 | 14 17 | 20 23
assert(map(0,0,0) == 0);
assert(map(1,0,0) == 6);
assert(map(0,1,0) == 1);
assert(map(0,0,1) == 3);
assert(map(3,2,1) == 23);
}
24
#include <cassert>
#include <array>
#include <mdspan>
int main()
{
using Ext3D = std::dextents<size_t, 3>;
using Mapping = std::layout_stride::mapping<Ext3D>;
std::array strides{6, 1, 3};
Mapping map{Ext3D{4, 3, 2}, strides};
// map(i,j,k):
// i= 0 | 1 | 2 | 3
// ------+-------+-------+-------
// j/k ->
// | 0 3 | 6 9 | 12 15 | 18 21
// V 1 4 | 7 10 | 13 16 | 19 22
// 2 5 | 8 11 | 14 17 | 20 23
assert(map(0,0,0) == 0);
出力
バージョン
言語
- C++23
処理系
- Clang: ??
- GCC: ??
- ICC: ??
- Visual C++: ??