std::mdspan<T,Extents,LayoutPolicy,AccessorPolicy>::operator[]
From cppreference.com
C++
Feature test macros (C++20)
Concepts library (C++20)
Metaprogramming library (C++11)
Ranges library (C++20)
Filesystem library (C++17)
Concurrency support library (C++11)
Execution control library (C++26)
Containers library
(C++17)
(C++11)
(C++26)
(C++26)
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
(C++23)
(C++23)
(C++23)
(C++23)
(C++20)
(C++23)
Tables
std::mdspan
mdspan::operator[]
(C++26)
(C++26)
(C++26)
(C++26)
(C++26)
(C++26)
(C++26)
(C++26)
(C++26)
template< class... OtherIndexTypes >
constexpr reference operator[]( OtherIndexTypes... indices ) const;
(1)
(since C++23)
constexpr reference operator[]( OtherIndexTypes... indices ) const;
template< class OtherIndexType >
(2)
(since C++23)
constexpr reference operator[]
template< class OtherIndexType >
(3)
(since C++23)
constexpr reference operator[]
Returns a reference to the indicesth element of the mdspan.
1) Equivalent to return
acc_
.access(ptr_
,
map_
(static_cast<index_type>(std::move(indices))...));. This overload participates in overload resolution only if all following values are true:
- (std::is_convertible_v <OtherIndexTypes, index_type> && ...)
- (std::is_nothrow_constructible_v <index_type, OtherIndexTypes> && ...)
- sizeof...(OtherIndexTypes) == rank()
If extents_type::index-cast
(std::move(indices)) is not a multidimensional index in extents(), the behavior is undefined.
If extents_type::index-cast
(std::move(indices)) is not a multidimensional index in extents():
- If the implementation is hardened, a contract violation occurs. Moreover, if the contract-violation handler returns under "observe" evaluation semantic, the behavior is undefined.
- If the implementation is not hardened, the behavior is undefined.
2,3) Let
std::index_sequence <P...>> is true, equivalent to return operator[](extents_type::
P
be a parameter pack such that std::is_same_v <std::make_index_sequence <rank()>,std::index_sequence <P...>> is true, equivalent to return operator[](extents_type::
index-cast
(std::as_const (indices[P]))...);. This overload participates in overload resolution only if all following values are true:
- std::is_convertible_v <const OtherIndexType&, index_type>
- std::is_nothrow_constructible_v <index_type, const OtherIndexType&>
[edit] Parameters
indices
-
the indices of the element to access
[edit] Return value
A reference to the element.
[edit] Example
This section is incomplete
Reason: no example
Reason: no example
[edit] Defect reports
The following behavior-changing defect reports were applied retroactively to previously published C++ standards.
DR | Applied to | Behavior as published | Correct behavior |
---|---|---|---|
LWG 3974 | C++23 | overloads (2,3) did not apply extents_type:: index-cast
|
applies |
[edit] See also
This section is incomplete