On this page
std::mdspan<T,Extents,LayoutPolicy,AccessorPolicy>::operator[]
|
(1) | (since C++23) |
|
(2) | (since C++23) |
|
(3) | (since C++23) |
Returns a reference to the indicesth element of the mdspan.
return acc_.access(ptr_, map_(static_cast<index_type>(std::move(indices))...));.
- This overload participates in overload resolution only if:
(std::is_convertible_v<OtherIndexTypes, index_type> && ...)istrue,(std::is_nothrow_constructible_v<index_type, OtherIndexTypes> && ...)istrue, andsizeof...(OtherIndexTypes) == rank()istrue.- Let
Ibeextents_type::index-cast(std::move(indices)). Then the behavior is undefined ifIis not a multidimensional index inextents(), i.e.,map_(I) < map_.required_span_size()isfalse.
P be a parameter pack such that std::is_same_v<make_index_sequence<rank()>, index_sequence<P...>> is true, then the operator is equivalent to return operator[](std::as_const(indices[P])...);.
- This overload participates in overload resolution only if:
std::is_convertible_v<const OtherIndexType&, index_type>istrue, andstd::is_nothrow_constructible_v<index_type, const OtherIndexType&>istrue.
Parameters
| indices | - | the indices of the element to access |
Return value
A reference to the element.
Example
See also
© cppreference.com
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
https://en.cppreference.com/w/cpp/container/mdspan/operator_at