std::ranges::stride_view<V>::iterator<Const>::operator[]
ja.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)
|
要素にアクセスする
(公開メンバ関数) |