std::ranges...r++,--,+=,-=(3)
π NAME π
bestie, welcome to the std::ranges...r++,--,+=,-=(3) page from the C++ Standard Libary manual. This page is all about std::ranges::stride_view::iterator::operator++,--,+=,-= β and yes, the name is literally std::ranges::stride_view::iterator::operator++,--,+=,-= twice in the original NAME section, so we're keeping both. It's giving βsay it again for the people in the back.β π
β¨ Synopsis β¨
okay so here's the whole lineup, and every single one is constexpr and since C++23:
constexpr /*iterator*/& operator++(); (1) (since C++23)
constexpr void operator++( int ); (2) (since C++23)
constexpr /*iterator*/ operator++( int ) (3) (since C++23)
requires ranges::forward_range<Base>;
constexpr /*iterator*/& operator--() (4) (since C++23)
requires ranges::bidirectional_range<Base>;
constexpr /*iterator*/ operator--( int ) (5) (since C++23)
requires ranges::bidirectional_range<Base>;
constexpr /*iterator*/& operator+=( difference_type n ) (6) (since C++23)
requires ranges::random_access_range<Base>;
constexpr /*iterator*/& operator-=( difference_type n ) (7) (since C++23)
requires ranges::random_access_range<Base>;
Increments or decrements the iterator. That's the whole vibe. π¦
Let current_, end_, stride_, and missing_ be the data members of the iterator. Keep those names close, they're about to do main-character stuff. π«Ά
- Equivalent to:
missing_ = ranges::advance(current_, stride_, end_);
return *this
Before the callcurrent_should not be equal toend_.
- Equivalent to
++*this;. - Equivalent to
auto tmp = *this; ++*this; return tmp;. - Equivalent to:
ranges::advance(current_, missing_ - stride_);
missing_ = 0;
return *this;
- Equivalent to
auto tmp = *this; --*this; return tmp;. - Equivalent to:
if (n > 0)
{
ranges::advance(current_, stride_ * (n - 1));
missing_ = ranges::advance(current_, stride_, end_);
}
else if (n < 0)
{
ranges::advance(current_, stride_ * n + missing_);
missing_ = 0;
}
return *this;
If n > 0, then before the call to this function the ranges::distance(current_, end_) must be greater than stride_ * (n - 1).
Note that if n < 0, the ranges::distance(current_, end_) is always greater than (non-positive) stride_ * (n - 1).
- Equivalent to
return *this += -n;.
πΈ Parameters πΈ
nβ position relative to current location
π Return value π
1,4,6,7β*this2β (none)3,5β a copy of*thisthat was made before the change
π Example π
This section is incomplete Reason: no example
not me crying over an empty example section π but that's literally what it says, so we're not inventing one. periodt.
π₯ See also π₯
operator+performs iterator arithmeticoperator-(function) (C++23)
π¦ Category π¦
- Todo no example
xoxo, your Unix bestie π β source: http://cppreference.com, date: 2024.06.10, page: std::ranges...r++,--,+=,-=(3) π
π¦ 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