| (1) | (since C++20) |
| (2) | (since C++20) |
| | |
The default implementation ofoperator[] member function obtains the element at the specified offset relative to the beginning iterator, reusing theoperator[] of the iterator type.
1) Let
derived be
static_cast<D&>(*this). Equivalent to
returnranges::begin(derived)[n];.
2) Same as(1), except thatderived isstatic_cast<const D&>(*this).
[edit]Parameters
| n | - | position of the element to return |
[edit]Return value
The element at offsetn relative to the beginning iterator.
In C++20, no type derived fromstd::ranges::view_interface in the standard library provides their ownoperator[] member function.
However, following derived types cannot use the default implementations, as they never satisfyrandom_access_range:
The inheritedoperator[] member function is available forstd::ranges::empty_view, but a call to it always results in undefined behavior.
[edit]Example
| This section is incomplete Reason: no example |