命名空间
变体
操作

std::ranges::repeat_view<W, Bound>::iterator

来自 cppreference.cn
< cpp‎ | ranges‎ | repeat view
 
 
范围库
范围适配器
 
 
struct /*iterator*/;
(仅为演示目的*)

ranges::repeat_view<W, Bound>::iteratorbegin()end() 返回的迭代器的类型,它们属于 ranges::repeat_view<W, Bound>

内容

[编辑] 嵌套类型

仅为演示目的类型
类型 定义
index-type std::conditional_t<std::same_as<Bound, std::unreachable_sentinel_t>,
                   std::ptrdiff_t, Bound>
(仅为演示目的成员类型*)
迭代器属性类型
类型 定义
iterator_concept std::random_access_iterator_tag
iterator_category std::random_access_iterator_tag
value_type W
difference_type std::conditional_t<is-signed-integer-like <index-type >,
                   index-type , iota-diff-t <index-type >>

[编辑] 数据成员

成员 定义
const W* value_ 指向要重复的值的指针
(仅为演示目的成员对象*)
index-type current_ 当前位置
(仅为演示目的成员对象*)

[编辑] 成员函数

std::ranges::repeat_view::iterator::iterator

/*iterator*/() = default;
(1) (自 C++23 起)
constexpr explicit /*iterator*/
    ( const W* value, /*index-type*/ b = /*index-type*/() );
(2) (自 C++23 起)
(仅为演示目的*)

构造一个迭代器。重载 (2)begin()end() of ranges::repeat_view 调用。

1) 使用 nullptr 初始化 value_,并对 current_  进行值初始化。
2) 使用 value 初始化 value_,并使用 b 初始化 current_
如果 Bound 不是 std::unreachable_sentinel_tb 为负数,则行为未定义。

std::ranges::repeat_view::iterator::operator*

constexpr const W& operator*() const noexcept;
(自 C++23 起)

返回 *value_

std::ranges::repeat_view::iterator::operator[]

constexpr const W& operator[]( difference_type n ) const noexcept;
(自 C++23 起)

返回 *(*this + n)

std::ranges::repeat_view::iterator::operator++

constexpr /*iterator*/& operator++();
(1) (自 C++23 起)
constexpr void operator++(int);
(2) (自 C++23 起)
1) 等价于 ++current_ ; return *this;
2) 等价于 auto tmp = *this; ++*this; return tmp;

std::ranges::repeat_view::iterator::operator--

constexpr /*iterator*/& operator--();
(1) (自 C++23 起)
constexpr /*iterator*/ operator--(int);
(2) (自 C++23 起)
1) 等价于 --current_ ; return *this;
如果 Bound 不是 std::unreachable_sentinel_tcurrent_ 为非正数,则行为未定义。
2) 等价于 auto tmp = *this; --*this; return tmp;

std::ranges::repeat_view::iterator::operator+=

constexpr /*iterator*/& operator+=( difference_type n );
(自 C++23 起)

等价于 current_ += n; return *this;

如果 Bound 不是 std::unreachable_sentinel_tcurrent_ + n 为负数,则行为未定义。

std::ranges::repeat_view::iterator::operator-=

constexpr /*iterator*/& operator-=( difference_type n );
(自 C++23 起)

等价于 current_ -= n; return *this;

如果 Bound 不是 std::unreachable_sentinel_tcurrent_ - n 为负数,则行为未定义。

[编辑] 非成员函数

operator==, <=>(std::ranges::repeat_view::iterator)

friend constexpr bool operator==
    ( const /*iterator*/& x, const /*iterator*/& y );
(1) (自 C++23 起)
friend constexpr auto operator<=>
    ( const /*iterator*/& x, const /*iterator*/& y );
(2) (自 C++23 起)
1) 返回 x.current_ == y.current_
2) 返回 x.current_ <=> y.current_

!= 运算符是从 operator== 合成的

这些函数对于普通的非限定限定查找是不可见的,并且只有当 iterator 是参数的关联类时,才能通过实参依赖查找找到。

operator+(std::ranges::repeat_view::iterator)

friend constexpr /*iterator*/ operator+
    ( /*iterator*/ i, difference_type n );
(1) (自 C++23 起)
friend constexpr /*iterator*/ operator+
    ( difference_type n, /*iterator*/ i );
(2) (自 C++23 起)

等价于 i += n; return i;

这些函数对于普通的非限定限定查找是不可见的,并且只有当 iterator 是参数的关联类时,才能通过实参依赖查找找到。

operator-(std::ranges::repeat_view::iterator)

friend constexpr /*iterator*/ operator-
    ( /*iterator*/ i, difference_type n );
(1) (自 C++23 起)
friend constexpr difference_type operator-
    ( const /*iterator*/& x, const /*iterator*/& y );
(2) (自 C++23 起)
1) 等价于 i -= n; return i;
2) 返回 static_cast<difference_type>(x.current_ ) -
    static_cast<difference_type>(y.current_ )

这些函数对于普通的非限定限定查找是不可见的,并且只有当 iterator 是参数的关联类时,才能通过实参依赖查找找到。

[编辑] 注解

iterator 始终是 random_access_iterator