std::ranges...w::iterator(3)
π NAME π
std::ranges::repeat_view::iterator β yeah bestie, that's the whole name, it's the iterator type for std::ranges::repeat_view, brought to you by the C++ Standard Library manual β¨ (and yes, the manual name is literally "C++ Standard Library", we're fancy like that π
)
π SYNOPSIS π
struct /*iterator*/; (since C++23)
(exposition only*)
The return type of repeat_view::begin. That's the entire vibe, no cap π«Ά
π MEMBER TYPES π
index-typeβ ok so it'sstd::ptrdiff_tifBoundis the same asstd::unreachable_sentinel_t. Otherwise? It'sBound. Simple as that. (exposition-only member type*)iterator_conceptβstd::random_access_iterator_tagπiterator_categoryβstd::random_access_iterator_tag, yeah same one, she's consistentvalue_typeβWdifference_typeβ so it's/*index-type*/if/*is-signed-like*/</*index-type*/>is true, and/*iota-diff-t*/(/*index-type*/)otherwise, where/*iota-diff-t*/has the same meaning as iniota_view. Iykyk π§
π DATA MEMBERS π
value_(private) β a pointer of typeconst W*that holds the pointer to the value to repeat. (exposition-only member object*)current_(private) β an object of type/*index-type*/that holds the current position. (exposition-only member object*)
π¦ MEMBER FUNCTIONS π¦
- constructor (C++23) β constructs an iterator (public member function)
operator*(C++23) β returns the current subrange (public member function)operator[](C++23) β accesses an element by index (public member function)operator++,operator++(int),operator--,operator--(int),operator+=,operator-=(C++23) β advances or decrements the underlying iterator (public member function)
π std::ranges::repeat_view::iterator::iterator
/*iterator*/() = default; (1) (since C++23)
constexpr explicit /*iterator*/( (2) (since C++23)
const W* value, /*index-type*/ b = /*index-type*/() );
(exposition only*)
- Value initializes the data members:
value_withnullptr_tvia its default member initializer;index_via its default member initializer (= /*index-type*/()). - Value initializes
value_withvalueandbound_withb. IfBoundis notstd::unreachable_sentinel_tthenbmust be non-negative. Heads up bestie: this constructor is not a part of the public interface π
πΈ std::ranges::repeat_view::iterator::operator*
constexpr const W& operator*() const noexcept; (since C++23)
Equivalent to return *value_;. That's it, she dereferences and serves π
β¨ std::ranges::repeat_view::iterator::operator[]
constexpr const W& operator[]( difference_type n ) const noexcept; (since C++23)
Equivalent to return *(*this + n);. Index math, iconic behavior π
π std::ranges::repeat_view::iterator::operator++
constexpr /*iterator*/& operator++(); (1) (since C++23)
constexpr void operator++(int); (2) (since C++23)
- Equivalent to
++current_; return *this;. - Equivalent to
auto tmp = *this; ++*this; return tmp;.
Post-increment lowkey makes a copy first, that's just how she rolls π
π¦ std::ranges::repeat_view::iterator::operator--
constexpr /*iterator*/& operator--(); (1) (since C++23)
constexpr /*iterator*/ operator--(int); (2) (since C++23)
- Equivalent to
--current_; return *this;. IfBoundis notstd::unreachable_sentinel_tthenbound_must be positive β οΈ - Equivalent to
auto tmp = *this; --*this; return tmp;.
π std::ranges::repeat_view::iterator::operator+=
constexpr /*iterator*/& operator+=( difference_type n ); (since C++23)
Equivalent to current_ += n; return *this;. If Bound is not std::unreachable_sentinel_t then (bound_ + n) must be non-negative. Don't be out here violating that, fr fr π«Ά
π§ std::ranges::repeat_view::iterator::operator-=
constexpr /*iterator*/& operator-=( difference_type n ); (since C++23)
Equivalent to current_ -= n; return *this;. If Bound is not std::unreachable_sentinel_t, then (bound_ - n) must be non-negative. Same energy, opposite direction β¨
π₯ NON-MEMBER FUNCTIONS π₯
operator==,operator<=>(C++23) β compares the underlying iterators (function)operator+,operator-(C++23) β performs iterator arithmetic (function)
π operator==, <=>(std::ranges::repeat_view::iterator)
friend constexpr bool operator==( const /*iterator*/& x, const (1) (since C++23)
/*iterator*/& y );
friend constexpr auto operator<=>( const /*iterator*/& x, const (2) (since C++23)
/*iterator*/& y );
- Equivalent to
x.current_ == y.current_. - Equivalent to
x.current_ <=> y.current_.
The != operator is synthesized from operator== β she doesn't need her own, she's built different π
Ok so listen: these functions are not visible to ordinary unqualified or qualified lookup, and can only be found by argument-dependent lookup when iterator is an associated class of the arguments. ADL only, bestie, that's the rule π
π operator+(std::ranges::repeat_view::iterator)
friend constexpr /*iterator*/ operator+( /*iterator*/ i, (1) (since C++23)
difference_type n );
friend constexpr /*iterator*/ operator+( difference_type n, (2) (since C++23)
/*iterator*/ i );
Equivalent to i += n; return i;. Both orders work, she's flexible like that π¦
Same caveat as before: these functions are not visible to ordinary unqualified or qualified lookup, and can only be found by argument-dependent lookup when iterator is an associated class of the arguments.
β operator-(std::ranges::repeat_view::iterator)
friend constexpr /*iterator*/ operator-( /*iterator*/ i, (1) (since C++23)
difference_type n );
friend constexpr difference_type operator-( const /*iterator*/& x, (2) (since C++23)
const /*iterator*/& y );
- Equivalent to
i -= n; return i;. - Equivalent to
return static_cast<difference_type>(x.current_) - static_cast<difference_type>(y.current_);.
And once more for the people in the back: these functions are not visible to ordinary unqualified or qualified lookup, and can only be found by argument-dependent lookup when iterator is an associated class of the arguments. π
π NOTES π
iterator is always random_access_iterator. Always. Periodt. π
π₯
Ok that's the whole page bestie, you ate that π«Ά This masterpiece came to you courtesy of http://cppreference.com, dated 2024.06.10 β go off, and remember: no cap, only C++23 β¨ππ
π¦ where this page comes from
- nixpkgs unstable: stdman 2024.07.05
- opensuse-leap 16.0: stdman 2024.07.05-bp160.1.9 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms