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となるとき、以下と等価。
例外
投げない
例
#include <cassert>
#include <mdspan>
int main()
{
using Ext3x4 = std::extents<size_t, 3, 4>;
using Mapping3x4 = std::layout_left::mapping<Ext3x4>;
Mapping3x4 map;
assert(map(0,0) == 0);
assert(map(0,1) == 3);
assert(map(1,0) == 1);
assert(map(2,3) == 11);
}
出力
バージョン
言語
- C++23
処理系
- Clang: ??
- GCC: ??
- ICC: ??
- Visual C++: ??
参照
- P0009R18 MDSPAN
- LWG Issue 4314. Missing move in mdspan layout mapping::operator()
- C++26で、rvalueでのみ
index_typeへ変換できる型に対応するため、operator()の返し式でインデックス値をstd::moveするようになった
- C++26で、rvalueでのみ