Spec-Zone.ru › C++

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

template< class... OtherIndexTypes >
constexpr reference operator[]( OtherIndexTypes... indices ) const;
(1) (since C++23)
template< class OtherIndexType >
constexpr reference operator[]( std::span<OtherIndexType, rank()> indices ) const;
(2) (since C++23)
template< class OtherIndexType >
constexpr reference operator[]( const std::array<OtherIndexType, rank()>& indices ) const;
(3) (since C++23)

Возвращает ссылку на элемент mdspan с индексом 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) Пусть P — параметр-пакет, такой что std::is_same_v<make_index_sequence<rank()>, index_sequence<P...>> является true, тогда оператор эквивалентен return operator[](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 - индексы элемента для доступа

Возвращаемое значение

Ссылка на элемент.

Пример

См. также

© cppreference.com
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
https://en.cppreference.com/w/cpp/container/mdspan/operator_at

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API