std::ranges::repeat_view<W, Bound>::iterator
来自cppreference.com
< cpp | ranges | repeat view
struct /*iterator*/; | (仅用于阐述*) | |
ranges::repeat_view<W, Bound>::iterator
是 ranges::repeat_view<W, Bound> 的 begin()
和 end()
返回的迭代器的类型。
嵌套类型
仅用于阐述的类型 | |
类型 | 定义 |
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 起) (仅用于阐述*) |
构造迭代器。ranges::repeat_view
的 begin()
和 end()
会调用重载 (2)。
如果
Bound
不是 std::unreachable_sentinel_t 且 b 为负,那么行为未定义。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;。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_t 且 current_
+ n 为负,那么行为未定义。
std::ranges::repeat_view::iterator::operator-=
constexpr /*iterator*/& operator-=( difference_type n ); | (C++23 起) | |
等价于 current_
-= n; return *this;。
如果 Bound
不是 std::unreachable_sentinel_t 且 current_
- 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 起) |
!=
运算符从 operator==
运算符合成。
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;。
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
始终是 random_access_iterator
。