Namespaces
Variants

std::ranges::stride_view<V>:: iterator <Const>:: operator[]

From cppreference.net
Ranges library
Range adaptors
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)