std::mdspan<T,Extents,LayoutPolicy,AccessorPolicy>::operator[]
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-й.
1) Эквивалентно
Эта перегрузка участвует в разрешении перегрузки только в том случае, если все следующие значения равны return acc_ .access(ptr_, map_ (static_cast<index_type>(std::move(indices))...));.true: (std::is_convertible_v<OtherIndexTypes, index_type> && ...)(std::is_nothrow_constructible_v<index_type, OtherIndexTypes> && ...)sizeof...(OtherIndexTypes) == rank()
| Если | (до C++26) |
| Если
| (с 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: std::is_convertible_v<const OtherIndexType&, index_type>std::is_nothrow_constructible_v<index_type, const OtherIndexType&>
Параметры
| indices | - | индексы элемента, к которому осуществляется доступ |
Возвращаемое значение
Ссылка на элемент.
Пример
Отчёты об ошибках
Следующие отчёты об ошибках, изменяющие поведение, были ретроактивно применены к ранее опубликованным стандартам C++.
| DR | Применяется к | Поведение согласно опубликованному тексту | Корректное поведение |
|---|---|---|---|
| LWG 3974 | C++23 | перегрузки (2,3) не применяли extents_type::index-cast | применяют |
См. также
© cppreference.com
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
https://en.cppreference.com/cpp/container/mdspan/operator_at