命名空间
变体
操作

std::ranges::adjacent_view<V,N>::begin

来自 cppreference.cn
 
 
范围库
范围适配器
 
 
constexpr auto begin() requires (!__SimpleView<V>);
(1) (自 C++23 起)
constexpr auto begin() const requires ranges::range<const V>;
(2) (自 C++23 起)

返回指向 adjacent_view 的首个元素的 iterator

base_ 为底层的视图。

1) 等价于 return /*iterator*/<false>(ranges::begin(base_), ranges::end(base_));
2) 等价于 return /*iterator*/<true>(ranges::begin(base_), ranges::end(base_));

内容

[edit] 参数

(无)

[edit] 返回值

指向首个元素的迭代器。

[edit] 示例

#include <ranges>
#include <tuple>
#include <type_traits>
 
int main()
{
    constexpr static auto v = {'A', 'B', 'C', 'D', 'E'};
 
    constexpr auto view = std::views::adjacent<3>(v);
 
    constexpr auto tuple = *view.begin();
 
    static_assert
    (
        std::is_same_v
        <
            decltype(tuple),
            const std::tuple<char const&, char const&, char const&>
        >
    );
 
    static_assert
    (
        std::get<0>(tuple) == 'A' &&
        std::get<1>(tuple) == 'B' &&
        std::get<2>(tuple) == 'C'
    );
}

[edit] 参见

返回指向末尾的迭代器或哨位
(公开成员函数) [edit]
返回指向范围开始的迭代器
(定制点对象)[edit]