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

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

πŸ’– NAME πŸ’–

okay so bestie, welcome to the C++ Standard Libary manual (yes, β€œLibary” is the spelling from the source, we are not fixing it πŸ’…). this page is std::basic_...++,--,+=,-=(3), and the main character is std::basic_const_iterator::operator++,--,+=,-=.

std::basic_const_iterator::operator++,--,+=,-= β€” that's the name. std::basic_const_iterator::operator++,--,+=,-= β€” yep, same name again. the source really said it twice and we're keeping the duplicate because every detail stays. periodt. πŸ’–


🌸 Synopsis 🌸

here's the whole overload lineup, copied exactly so nobody comes for me:

          constexpr basic_const_iterator& operator++();                   (1)
       (since C++23)
          constexpr void operator++(int);                                 (2)
       (since C++23)
          constexpr basic_const_iterator operator++(int)                  (3)
       (since C++23)
              requires std::forward_iterator<Iter>;
          constexpr basic_const_iterator& operator--()                    (4)
       (since C++23)
              requires std::bidirectional_iterator<Iter>;
          constexpr basic_const_iterator operator--(int)                  (5)
       (since C++23)
              requires std::bidirectional_iterator<Iter>;
          constexpr basic_const_iterator& operator+=( difference_type n ) (6)
       (since C++23)
              requires std::random_access_iterator<Iter>;
          constexpr basic_const_iterator& operator-=( difference_type n ) (7)
       (since C++23)
              requires std::random_access_iterator<Iter>;

so yeah, every one of these is since C++23, and the requires clauses are doing their little gatekeeping thing. ✨

the actual vibe: these increment or decrement the iterator by applying the corresponding operation on the underlying iterator. no cap.

  • 1–3 increment by one. πŸ’…
  • 4,5 decrement by one. πŸ¦‹
  • 6,7 advance the iterator by n or -n positions respectively. πŸ”₯

πŸŽ€ Return value πŸŽ€

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

πŸ¦‹ Example πŸ¦‹

This section is incomplete. Reason: no example.

no example bestie 😭 it's giving β€œtodo” energy. but we move.

🌈 See also 🌈

  • operator++
  • operator++(int)
  • operator+=
  • operator+ β€” advances or decrements the iterator
  • operator-- β€” (public member function of std::move_iterator<Iter>)
  • operator--(int)
  • operator-=
  • operator-
  • (C++11)

πŸ’€ Category πŸ’€

  • Todo no example

mwah πŸ’‹ β€” source http://cppreference.com, version/date 2024.06.10, page std::basic_...++,--,+=,-=(3). bye bestie, go increment something 🫢

πŸ“¦ where this page comes from