std::ranges...++,--,+=,-=(3)

πŸ“¦ version 2024.07.05, in nixpkgs unstable, opensuse-leap 16.0

✨ std::ranges::slide_view::iterator::operator++,--,+=,-= ✨

okay bestie, this is the C++ Standard Libary manpage for the slide_view iterator’s movement operators. It’s giving β€œiterator cardio” and honestly it ate. Let’s go πŸ’…


🌸 NAME 🌸

std::ranges::slide_view::iterator::operator++,--,+=,-= -
std::ranges::slide_view::iterator::operator++,--,+=,-=

πŸ¦‹ Synopsis πŸ¦‹

Every single one of these is constexpr and (since C++23). Here’s the synopsis, verbatim bestie:

constexpr /*iterator*/& operator++();                   (1) (since C++23)
constexpr /*iterator*/ operator++( int );               (2) (since C++23)
constexpr /*iterator*/& operator--()                    (3) (since C++23)
    requires ranges::bidirectional_range<Base>;
constexpr /*iterator*/ operator--( int )                (4) (since C++23)
    requires ranges::bidirectional_range<Base>;
constexpr /*iterator*/& operator+=( difference_type n ) (5) (since C++23)
    requires ranges::random_access_range<Base>;
constexpr /*iterator*/& operator-=( difference_type n ) (6) (since C++23)
    requires ranges::random_access_range<Base>;

Advances or decrements the iterator.

Let current_ and last_ele_ be the underlying iterators to the begin and end of the sliding window.

  • (1) operator++() β€” equivalent to:
current_ = ranges::next(current_);
last_ele_ = ranges::next(last_ele_); // if last_ele_ is present
return *this;

Before the invocation, the current_ and last_ele_ (if present) must be incrementable.

  • (2) operator++( int ) β€” equivalent to:
auto tmp = *this; ++*this; return tmp;
  • (3) operator--() β€” equivalent to:
current_ = ranges::prev(current_);
last_ele_ = ranges::prev(last_ele_); // if last_ele_ is present
return *this;

Before the invocation, the current_ and last_ele_ (if present) must be decrementable.

  • (4) operator--( int ) β€” equivalent to:
auto tmp = *this; --*this; return tmp;
  • (5) operator+=( difference_type n ) β€” equivalent to:
current_ = current_ + n;
last_ele_ = last_ele_ + n; // if last_ele_ is present
return *this;

Before the invocation, the expressions current_ + n and last_ele_ + n (if last_ele_ is present) must have well-defined behavior.

  • (6) operator-=( difference_type n ) β€” equivalent to:
current_ = current_ - n;
last_ele_ = last_ele_ - n; // if last_ele_ is present
return *this;

Before the invocation, the expressions current_ - n and last_ele_ - n (if last_ele_ is present) must have well-defined behavior.


πŸŽ€ Parameters πŸŽ€

  • n β€” position relative to current location.

πŸ’– Return value πŸ’–

  • 1, 3, 5, 6) *this
  • 2, 4) a copy of *this that was made before the change

🧚 Example 🧚

This section is incomplete.

Reason: no example.


πŸ‘‘ See also πŸ‘‘

  • operator+ performs iterator arithmetic
  • operator- (function) (C++23)

🌈 Category 🌈

  • Todo no example

Source/version + date check, bestie: this came from http://cppreference.com, dated 2024.06.10, and the page is std::ranges...++,--,+=,-=(3). Periodt πŸ’…βœ¨πŸ«Ά

πŸ“¦ where this page comes from