std::ranges::adjacent_view<V,N>::iterator<Const>::operator*
来自 cppreference.cn
< cpp | ranges | adjacent view | 迭代器
constexpr auto operator*() const; |
(C++23 起) | |
返回迭代器指向的底层迭代器数组中的元素到 V 中。
令 current_
为底层迭代器数组。
等价于
return /*tuple-transform*/([](auto& i) -> decltype(auto) { return *i; }, current_);
目录 |
[编辑] 参数
(无)
[编辑] 返回值
当前元素,它是对底层元素的引用的 std::tuple。
[编辑] 注意
未提供 operator->。
[编辑] 示例
运行此代码
#include <ranges> #include <tuple> int main() { constexpr static auto v = {0, 1, 2, 3, 4, 5}; // └──┬──┘ // └─────────────────┐ constexpr auto view {v | std::views::adjacent<3>}; // │ constexpr auto iter {view.begin() + 2}; // │ // ┌────────────────────┬────────────────┘ // │ ┌──┴──┐ static_assert(*iter == std::tuple{2, 3, 4}); }
[编辑] 参阅
(C++23) |
通过索引访问元素 (公开成员函数) |