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

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

std::ranges::transform_view::iterator πŸ’…βœ¨

okay bestie, this is a C++ Standard Libary manual page, section (3), and it's giving β€œniche iterator class that is actually iconic.” let’s get into it 🫢

πŸ’– NAME πŸ’–

std::ranges::transform_view::iterator β€” std::ranges::transform_view::iterator

✨ Synopsis ✨

template< bool Const >  (since C++20)
class /*iterator*/      (exposition only*)

The return type of transform_view::begin, and of transform_view::end when the underlying view is a common_range.

The type /*iterator*/<true> is returned by the const-qualified overloads. The type /*iterator*/<false> is returned by the non-const-qualified overloads.

πŸ¦‹ Member types πŸ¦‹

Here’s the member-type lore, with no skipped rows πŸ’–

  • Parent (private) β€” const ranges::transform_view<V, F> if Const is true, otherwise ranges::transform_view<V, F>. (exposition-only member type*)
  • Base (private) β€” const V if Const is true, otherwise V. (exposition-only member type*)
  • iterator_concept β€” the tag depends on Base:
    • std::random_access_iterator_tag if Base models random_access_range,
    • std::bidirectional_iterator_tag if Base models bidirectional_range,
    • std::forward_iterator_tag if Base models forward_range,
    • std::input_iterator_tag otherwise.
  • iterator_category β€” the rules are:
    • Not defined if Base does not model forward_range.
    • Otherwise, if std::invoke_result_t<F&, ranges::range_reference_t<Base>> is not a reference, std::input_iterator_tag.
    • Else, let C be std::iterator_traits<ranges::iterator_t<Base>>::iterator_category. If C is std::contiguous_iterator_tag, the type is std::random_access_iterator_tag; otherwise, the type is C.
  • value_type β€” std::remove_cvref_t<std::invoke_result_t<F&, ranges::range_reference_t<Base>>>
  • difference_type β€” ranges::range_difference_t<Base>

πŸ’Ύ Data members πŸ’Ύ

  • current_ (private) β€” an iterator into (possibly const-qualified) V. (exposition-only member object*)
  • parent_ (private) β€” a pointer to parent transform_view. (exposition-only member object*)

πŸŽ€ Member functions πŸŽ€

  • constructor (C++20) β€” constructs an iterator (public member function).
  • base (C++20) β€” returns the underlying iterator (public member function).
  • operator* (C++20) β€” accesses the transformed element (public member function).
  • operator[] (C++20) β€” accesses an element by index (public member function).
  • operator++, operator++(int), operator--, operator--(int) (C++20) β€” advances or decrements the underlying iterator (public member function).
  • operator+=, operator-= (C++20) β€” listed here with no extra one-liner in the original list 🫢

🌈 Non-member functions 🌈

  • operator==, operator<, operator>, operator<=, operator>=, operator<=> (C++20) β€” compares the underlying iterators (function).
  • operator+, operator- (C++20) β€” performs iterator arithmetic (function).
  • iter_move (C++20) β€” obtains an rvalue reference to the transformed element (function).

πŸ’€ Defect reports πŸ’€

The following behavior-changing defect reports were applied retroactively to previously published C++ standards.

  • P2259R1 β€” applied to C++20. Behavior as published: member iterator_category is always defined. Correct behavior: defined only if Base models forward_range.
  • LWG 3555 β€” applied to C++20. Behavior as published: the definition of iterator_concept ignores const. Correct behavior: made to consider const.
  • LWG 3798 β€” applied to C++20. Behavior as published: iterator_category is input-only if transformation result is rvalue reference. Correct behavior: may have a stronger category.

That’s the whole page, bestie πŸ’‹ β€” source http://cppreference.com, dated 2024.06.10, page std::ranges...ew::iterator(3). periodt πŸŽ€

πŸ“¦ where this page comes from