Namespaces
Variants

std::mdspan<T,Extents,LayoutPolicy,AccessorPolicy>:: operator[]

From cppreference.net
template < class ... OtherIndexTypes >
constexpr reference operator [ ] ( OtherIndexTypes... indices ) const ;
(1) (C++23以降)
template < class OtherIndexType >

constexpr reference operator [ ]

( std:: span < OtherIndexType, rank ( ) > indices ) const ;
(2) (C++23以降)
template < class OtherIndexType >

constexpr reference operator [ ]

( const std:: array < OtherIndexType, rank ( ) > & indices ) const ;
(3) (C++23以降)

mdspanの indices th 要素への参照を返します。

1) 次と同等: return acc_  . access ( ptr_ , map_  ( static_cast < index_type > ( std :: move ( indices ) ) ... ) ) ; .
このオーバーロードは、以下のすべての値が true である場合にのみオーバーロード解決に参加します:

extents_type:: index-cast (std::move(indices)) が extents() の多次元インデックスでない場合、動作は未定義です。

(C++26まで)

extents_type:: index-cast (std::move(indices)) が extents() の多次元インデックスでない場合:

  • 実装が ハードニング されている場合、 契約違反 が発生します。さらに、契約違反ハンドラが「observe」評価セマンティクスの下で戻った場合、動作は未定義です。
  • 実装がハードニングされていない場合、動作は未定義です。
(C++26以降)
2,3) P を、 std:: is_same_v < std:: make_index_sequence < rank ( ) > ,
std:: index_sequence < P... >>
true となるパラメータパックとする。これは return operator [ ] ( extents_type :: index-cast  ( std:: as_const ( indices [ P ] ) ) ... ) ; と等価である。
このオーバーロードは、以下のすべての値が true の場合にのみ、オーバーロード解決に参加します:

目次

パラメータ

indices - アクセスする要素のインデックス

戻り値

要素への参照。

不具合報告

以下の動作変更の欠陥報告書は、以前に公開されたC++規格に対して遡及的に適用されました。

DR 適用対象 公開時の動作 正しい動作
LWG 3974 C++23 オーバーロード (2,3) extents_type:: index-cast を適用しなかった 適用する

関連項目