std::mdspan<T,Extents,LayoutPolicy,AccessorPolicy>::operator[]
From cppreference.com
| template< class... OtherIndexTypes > constexpr reference operator[]( OtherIndexTypes... indices ) const; |
(1) | (C++23から) |
| template< class OtherIndexType > constexpr reference operator[] |
(2) | (C++23から) |
| template< class OtherIndexType > constexpr reference operator[] |
(3) | (C++23から) |
指定された indices の要素への参照を返します。
1) return acc_.access(ptr_, map_(static_cast<index_type>(std::move(indices))...)); と等価です。
このオーバーロードは、
- (std::is_convertible_v<OtherIndexTypes, index_type> && ...) が true であり、
- (std::is_nothrow_constructible_v<index_type, OtherIndexTypes> && ...) が true であり、
- sizeof...(OtherIndexTypes) == rank() が true である。
I を extents_type::index-cast(std::move(indices)) とします。I が extents() における多次元インデックスでない場合(すなわち、map_(I) < map_.required_span_size() が false である場合)は、未定義の動作です。2,3) template< class... auto P > requires std::is_same_v<make_index_sequence<rank()>, index_sequence<P...>> のようなパラメータパック
P が存在する場合、この演算子は return operator[](extents_type::index-cast(std::as_const(indices[P]))...); と等価です。 このオーバーロードは、
- std::is_convertible_v<const OtherIndexType&, index_type> が true であり、
- std::is_nothrow_constructible_v<index_type, const OtherIndexType&> が true である。
目次 |
[編集] パラメータ
| indices | - | アクセスする要素のインデックス |
[編集] 戻り値
要素への参照。
[編集] 例
| このセクションは未完成です 理由: 例がありません |
[編集] 欠陥レポート
以下の動作変更を伴う欠陥報告が、以前に公開されたC++標準に遡って適用されました。
| DR | 適用対象 | 公開された動作 | 正しい動作 |
|---|---|---|---|
| LWG 3974 | C++23 | オーバーロード (2,3) は extents_type::index-cast を適用していませんでした。 |
適用中 |
[編集] 関連項目
| このセクションは未完成です |