std::ranges...or::iterator(3)

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

NAME πŸŽ€

Okay bestie, welcome to the C++ Standard Libary manual page for std::ranges...or::iterator(3) β€” and the NAME section is doing that iconic double-tap: std::ranges::chunk_view::iterator::iterator β€” std::ranges::chunk_view::iterator::iterator. That's the name, and the description is literally the same thing. periodt. πŸ’…

Synopsis ✨

This is the constructor synopsis, and every line, every requires, and every little annotation is staying exactly as it appears. No cap. πŸ¦‹

          /*iterator*/() = default;                                     (1)
       (since C++23)
          constexpr /*iterator*/( /*iterator*/<!Const> i )

              requires
                  Const and
                  std::convertible_to<ranges::iterator_t<V>,            (2)
       (since C++23)
          ranges::iterator_t<Base>> and

                  std::convertible_to<ranges::sentinel_t<V>,
          ranges::sentinel_t<Base>>;
          private:

          constexpr /*iterator*/( Parent* parent,
                                  ranges::iterator_t<Base> current,     (3)
       (exposition only*)

                                  ranges::range_difference_t<Base>
          missing = 0 );

Construct an iterator. That's the whole mood of this page: we're constructing an iterator, and there are three flavors. 🫢

  1. Default constructor β€” /*iterator*/() = default; is (1), and it's (since C++23). It value-initializes the underlying data members:
    • current_ with ranges::iterator_t<Base>()
    • end_ with ranges::sentinel_t<Base>()
    • n_ with 0
    • missing_ with 0
  2. Conversion constructor β€” constexpr /*iterator*/( /*iterator*/<!Const> i ) is (2), and it's also (since C++23). It converts from /*iterator*/<false> to /*iterator*/<true>. Its requires clause is:
    • Const and
    • std::convertible_to<ranges::iterator_t<V>, ranges::iterator_t<Base>> and
    • std::convertible_to<ranges::sentinel_t<V>, ranges::sentinel_t<Base>>

It initializes the underlying data members:

  • current_ with std::move(i.current_)
  • end_ with std::move(i.end_)
  • n_ with i.n_
  • missing_ with i.missing_
  1. Private constructor β€” item (3), marked (exposition only*). It's the private one used by ranges::chunk_view::begin and ranges::chunk_view::end. The missing parameter defaults to 0. This constructor is not accessible to users β€” read it and weep, lol. 😭 It initializes the underlying data members:
    • current_ with current
    • end_ with ranges::end(parent->base_)
    • n_ with parent->n_
    • missing_ with missing
Wait, did we lose the missing = 0 default? Nope β€” it's right there in the constructor signature and it's staying. 🫢

Parameters πŸŽ€

  • i β€” an /*iterator*/<false>
  • parent β€” a pointer to owning chunk_view
  • current β€” an iterator to the begin of current chunk
  • missing β€” a difference between expected (n_) and actual size of current chunk

Example πŸ’€

This section is incomplete Reason: no example

Category πŸ‘‘

  • Todo no example

Mwah πŸ’‹ β€” source/version: http://cppreference.com; date: 2024.06.10; page: std::ranges...or::iterator(3). Stay hydrated and keep those iterators constructed. πŸ’–

πŸ“¦ where this page comes from