Namespaces
Variants

std::ranges::adjacent_view<V,N>::iterator<Const>::operator*

来自 zh.cppreference.net
 
 
范围库
范围适配器
 
 
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)
通过索引访问元素
(公开成员函数)