名前空間
変種
操作

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

From cppreference.com
< cpp‎ | container‎ | mdspan
 
 
 
 
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から)

指定された indices の要素への参照を返します。

1) return acc_.access(ptr_, map_(static_cast<index_type>(std::move(indices))...)); と等価です。
このオーバーロードは、
Iextents_type::index-cast(std::move(indices)) とします。Iextents() における多次元インデックスでない場合(すなわち、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]))...); と等価です。
このオーバーロードは、

目次

[編集] パラメータ

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

[編集] 戻り値

要素への参照。

[編集]

[編集] 欠陥レポート

以下の動作変更を伴う欠陥報告が、以前に公開されたC++標準に遡って適用されました。

DR 適用対象 公開された動作 正しい動作
LWG 3974 C++23 オーバーロード (2,3)extents_type::index-cast を適用していませんでした。 適用中

[編集] 関連項目

English 日本語 中文(简体) 中文(繁體)