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

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

πŸ’– std::ranges...++,--,+=,-=(3) πŸ’–

okay bestie, welcome to the C++ Standard Libary manual page for std::ranges::enumerate_view::iterator::operator++,--,+=,-=. Yes, the title is a whole keyboard smash and we are obsessed. This page is literally about std::ranges::enumerate_view::iterator::operator++,--,+=,-=. Slay.


πŸ’– NAME πŸ’–

  • std::ranges::enumerate_view::iterator::operator++,--,+=,-= β€” the full NAME entry is this exact gorgeous mouthful, and the description line is the same exact gorgeous mouthful: std::ranges::enumerate_view::iterator::operator++,--,+=,-=. No notes. πŸ‘‘

🌸 Synopsis 🌸

Here's the numbered cast, all since C++23, bestie:

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 job, and it ate. πŸ’…

Tiny vocab check: current_ is the underlying iterator, and pos_ is the underlying index. Now the receipts:

  • (1) Equivalent to ++current_; ++pos_; return *this;
  • (2) Equivalent to ++current_;
  • (3) Equivalent to auto tmp = *this; ++*this; return tmp;
  • (4) Equivalent to --current_; --pos_; return *this;
  • (5) Equivalent to auto tmp = *this; --*this; return tmp;
  • (6) Equivalent to current_ += n; pos_ += n; return *this;
  • (7) Equivalent to current_ -= n; pos_ -= n; return *this;

πŸŽ€ Parameters πŸŽ€

  • n β€” position relative to current location. That's the parameter, bestie. 🫢

✨ Return value ✨

  • 1,4,6,7) β€” *this
  • 2) β€” (none)
  • 3,5) β€” a copy of *this that was made before the change

πŸ¦‹ See also πŸ¦‹

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

and that's the page, bestie πŸ’… source/version + date from the footer: http://cppreference.com Β· 2024.06.10. periodt. πŸ’–

πŸ“¦ where this page comes from