std::experi...ardIterator(3)

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

🌸 NAME 🌸

okay so this is the std::experi...ardIterator(3) page from the C++ Standard Libary manual β€” yes, β€œLibary” with the typo, we are not fixing it πŸ’…. It’s all about:

  • std::experimental::ranges::ForwardIterator β€” the concept in question, bestie.
  • std::experimental::ranges::ForwardIterator β€” and yep, the original NAME section literally lists it twice, so we’re keeping both. periodt 🫢

✨ Synopsis ✨

The exact synopsis, no edits, no cap:

          Defined in header <experimental/ranges/iterator>
          template< class I >

          concept bool ForwardIterator =
              InputIterator<I> &&
              DerivedFrom<ranges::iterator_category_t<I>,
       (ranges TS)
          ranges::forward_iterator_tag> &&
              Incrementable<I> &&

              Sentinel<I, I>;

The concept ForwardIterator<I> refines InputIterator by adding equality comparison and the multi-pass guarantee. slay.

The domain of == for forward iterators is that of iterators over the same underlying sequence, except that value-initialized iterators of the same type may be compared with each other and shall compare equal. iykyk? That’s the rule. ✨

Pointers and references obtained from a forward iterator into a range [i, s) must remain valid while [i, s) continues to denote a range. no cap, they have to stay valid. 🫢

Let a and b be two dereferenceable iterators of type I. ForwardIterator<I> is satisfied only if:

  • a == b implies ++a == ++b; and
  • The expression ([](X x){ ++x; }(a), *a) is equivalent to *a, i.e., incrementing a copy of a has no effect on the result of dereferencing a.

This is known as the multi-pass guarantee. iconic, honestly. πŸ’–


πŸŽ€ Notes πŸŽ€

A forward iterator cannot be "stashing": it cannot return a reference to an object within itself, because such references would be invalidated by the destruction of the forward iterator. so no stashing, bestie β€” that would be a whole mess. πŸ’€


πŸ’– cute little footer sign-off: source http://cppreference.com, version/date 2024.06.10, page std::experi...ardIterator(3). that’s the whole footer, bestie β€” bye! 🫢✨
πŸ“¦ where this page comes from