std::ranges...w::iterator(3)
π std::ranges::iota_view::iterator π
okay bestie, welcome to the C++ Standard Libary manual page for std::ranges::iota_view::iterator π
this whole thing is straight-up exposition-only iterator main character energy, and we're getting into every detail. no cap.
πΈ NAME πΈ
std::ranges::iota_view::iterator β std::ranges::iota_view::iterator
β¨ Synopsis β¨
struct /*iterator*/; (1) (since C++20)
(exposition only*)
Helper alias templates
template< class I > (2) (exposition only*)
using /*iota-diff-t*/ = /* see below */;
Helper concepts
template< class I >
concept /*decrementable*/ =
std::incrementable<I> && requires(I i) { (3) (exposition only*)
{ --i } -> std::same_as<I&>;
{ i-- } -> std::same_as<I>;
};
template< class I >
concept /*advanceable*/ =
/*decrementable*/<I> && std::totally_ordered<I> &&
requires(I i, const I j, const /*iota-diff-t*/<I> n) {
{ i += n } -> std::same_as<I&>;
{ i -= n } -> std::same_as<I&>; (4) (exposition only*)
I(j + n);
I(n + j);
I(j - n);
{ j - j } -> std::convertible_to</*iota-diff-t*/<I>>;
};
- The return type of
iota_view::begin. - The alias template
/*iota-diff-t*/calculates the difference type for both iterator types and integer-like types.- If
Wis not an integral type, or if it is an integral type andsizeof(std::iter_difference_t<I>)is greater thansizeof(I), then/*iota-diff-t*/<I>isstd::iter_difference_t<I>. - Otherwise,
/*iota-diff-t*/<I>is a signed integer type of width greater than the width ofIif such a type exists. - Otherwise,
Iis one of the widest integral types, and/*iota-diff-t*/<I>is an unspecified signed-integer-like type of width not less than the width ofI. It is unspecified whether/*iota-diff-t*/<I>modelsweakly_incrementablein this case.
- If
- The concept
decrementablespecifies that a type isincrementable, and pre- and post-operator--for the type have common meaning. - The concept
advanceablespecifies that a type is bothdecrementableandtotally_ordered, andoperator+=,operator-=,operator+, andoperator-among the type and its different type have common meaning.
π Member types π
iterator_conceptβ here's the cascade, bestie:std::random_access_iterator_tagifWmodelsadvanceable.- Otherwise,
std::bidirectional_iterator_tagifWmodelsdecrementable. - Otherwise,
std::forward_iterator_tagifWmodelsincrementable. - Otherwise,
std::input_iterator_tag.
iterator_categoryβstd::input_iterator_tagifWmodelsincrementable. Otherwise, there is no member typeiterator_category.value_typeβWdifference_typeβ/*iota-diff-t*/<W>
Notes:/*iterator*/is -random_access_iteratorifWmodelsadvanceable, -bidirectional_iteratorifWmodelsdecrementable, -forward_iteratorifWmodelsincrementable, and -input_iteratorotherwise. However, it only satisfiesLegacyInputIteratorifWmodelsincrementable, and does not satisfyLegacyInputIteratorotherwise.
Data members
value_(private) β The value of typeWused for dereferencing. (exposition-only member object*)
π Member functions π
std::ranges::iota_view::iterator::iterator
/*iterator*/() requires std::default_initializable<W> = default; (1) (since C++20)
constexpr explicit /*iterator*/( W value ); (2) (since C++20)
- Value initializes the data member
value_via its default member initializer (= W()). - Initializes the data member
value_withvalue. This value will be returned byoperator*and incremented byoperator++.
std::ranges::iota_view::iterator::operator*
constexpr W operator*() const (since C++20)
noexcept(std::is_nothrow_copy_constructible_v<W>);
Returns the current value, by value (in other words, this is a read-only view). π«Ά
std::ranges::iota_view::iterator::operator++
constexpr /*iterator*/& operator++(); (1) (since C++20)
constexpr void operator++(int); (2) (since C++20)
constexpr /*iterator*/ operator++(int) requires (3) (since C++20)
std::incrementable<W>;
- Equivalent to
++value_; return *this;. - Equivalent to
++value_;. - Equivalent to
auto tmp = *this; ++value_; return tmp;.
std::ranges::iota_view::iterator::operator--
constexpr /*iterator*/& operator--() requires (1) (since C++20)
/*decrementable*/<W>;
constexpr /*iterator*/operator--(int) requires (2) (since C++20)
/*decrementable*/<W>;
- Equivalent to
--value_; return *this;. - Equivalent to
auto tmp = *this; --value_; return tmp;.
std::ranges::iota_view::iterator::operator+=
constexpr /*iterator*/& operator+=( difference_type n ) (since C++20)
requires /*advanceable*/<W>;
If W is unsigned-integer-like, performs value_ += static_cast<W>(n) if n is non-negative, value -= static_cast<W>(-n) otherwise, and then returns *this.
Otherwise, equivalent to value_ += n; return *this;.
std::ranges::iota_view::iterator::operator-=
constexpr /*iterator*/& operator-=( difference_type n ) (since C++20)
requires /*advanceable*/<W>;
If W is unsigned-integer-like, performs value_ -= static_cast<W>(n) if n is non-negative, or value += static_cast<W>(-n) otherwise, and then returns *this.
Otherwise, equivalent to value_ -= n; return *this;.
std::ranges::iota_view::iterator::operator[]
constexpr W operator[]( difference_type n ) const (since C++20)
requires /*advanceable*/<W>;
Equivalent to return W(value_ + n);.
π¦ Non-member functions π¦
operator==, <, >, <=, >=, <=>(std::ranges::iota_view::iterator)
friend constexpr bool operator== ( const /*iterator*/& x, const
/*iterator*/& y )
(1) (since C++20)
requires std::equality_comparable<W>;
friend constexpr bool operator< ( const /*iterator*/& x, const
/*iterator*/& y )
(2) (since C++20)
requires std::totally_ordered<W>;
friend constexpr bool operator> ( const /*iterator*/& x, const
/*iterator*/& y )
(3) (since C++20)
requires std::totally_ordered<W>;
friend constexpr bool operator<= ( const /*iterator*/& x, const
/*iterator*/& y )
(4) (since C++20)
requires std::totally_ordered<W>;
friend constexpr bool operator>= ( const /*iterator*/& x, const
/*iterator*/& y )
(5) (since C++20)
requires std::totally_ordered<W>;
friend constexpr bool operator<=>( const /*iterator*/& x, const
/*iterator*/& y )
(6) (since C++20)
requires std::totally_ordered<W> &&
std::three_way_comparable<W>;
- Equivalent to
return x.value_ == y.value_;. - Equivalent to
return x.value_ < y.value_;. - Equivalent to
return y < x;. - Equivalent to
return !(y < x);. - Equivalent to
return !(x < y);. - Equivalent to
return x.value_ <=> y.value_;.
The != operator is synthesized from operator==.
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::iota_view::iterator)
friend constexpr /*iterator*/ operator+( /*iterator*/ i,
difference_type n )
(1) (since C++20)
requires /*advanceable*/<W>;
friend constexpr /*iterator*/ operator+( difference_type n,
/*iterator*/ i )
(2) (since C++20)
requires /*advanceable*/<W>;
Equivalent to i += n; return i;.
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::iota_view::iterator)
friend constexpr /*iterator*/ operator-( /*iterator*/ i,
difference_type n )
(1) (since C++20)
requires /*advanceable*/<W>;
friend constexpr difference_type operator-( const /*iterator*/& x,
const /*iterator*/& y
(2) (since C++20)
)
requires /*advanceable*/<W>;
- Equivalent to
i -= n; return i;. - Let
Dbedifference_type.- If
Wis signed-integer-like, equivalent toreturn D(D(x.value_) - D(y.value_));. - Otherwise, if
Wis unsigned-integer-like, equivalent toreturn y.value_ > x.value_ ? D(-D(y.value_ - x.value_)) : D(x.value_ - y.value_);. - Otherwise, equivalent to
return x.value_ - y.value_;.
- If
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.
π₯ Defect reports π₯
The following behavior-changing defect reports were applied retroactively to previously published C++ standards.
- DR
P2259R1β applied toC++20; behavior as published: memberiterator_categoryis always defined; correct behavior: defined only ifWsatisfiesincrementable. - DR
LWG 3580β applied toC++20; behavior as published: bodies ofoperator+andoperator-rule out implicit move; correct behavior: made suitable for implicit move.
mwah π β source: http://cppreference.com, version/date: 2024.06.10; page footer name: std::ranges...w::iterator(3). that's the whole vibe, bestie π«Άβ¨
π¦ 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