std::ranges::stride_view<V>::iterator<Const>::operator[]
cppreference.net에서 가져옴
constexpr decltype(auto) operator[]( difference_type n ) const
requires ranges::random_access_range<Base>
|
(C++23부터) | |
지정된 상대 위치의 요소를 반환합니다.
다음과 동일: return *(*this + n);.
매개변수
| n | - | 현재 위치 기준 상대적 위치 |
반환값
현재 위치를 기준으로 변위 n 에 있는 요소입니다.
예제
이 코드 실행
#include <ranges> int main() { constexpr static auto v = {'a', 'b', 'c', 'd', 'e'}; constexpr auto view{v | std::views::stride(2)}; constexpr auto iter{view.begin() + 1}; static_assert(*iter == 'c'); static_assert(iter[0] == 'c'); static_assert(iter[1] == 'e'); }
참고 항목
|
(C++23)
|
요소에 접근
(public member function) |