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

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

🌸 NAME 🌸

std::ranges::elements_view::iterator β€” okay bestie, the original literally says the name twice, so here it is: std::ranges::elements_view::iterator. This page is from the C++ Standard Libary manual (yes, that’s the manual name, typo and all 🫢), and it’s all about the /*iterator*/ type that elements_view hands out.

✨ Synopsis ✨

template< bool Const >  (exposition only*)
class /*iterator*/;

It’s the return type of elements_view::begin, and of elements_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 πŸ’–

  • Base (private) β€” const V if Const is true, otherwise V. (exposition-only member type*)
  • iterator_concept β€” denotes:
    • std::random_access_iterator_tag, if Base models random_access_range. Otherwise,
    • std::bidirectional_iterator_tag, if Base models bidirectional_range. Otherwise,
    • std::forward_iterator_tag, if Base models forward_range. Otherwise,
    • std::input_iterator_tag.
  • iterator_category β€” not defined, if Base does not model forward_range. Otherwise,
    • std::input_iterator_tag, if std::get<N>(*current_) is an rvalue. Otherwise, let C be the type std::iterator_traits<std::iterator_t<Base>>::iterator_category.
    • std::random_access_iterator_tag, if C models std::derived_from<std::random_access_iterator_tag>. Otherwise,
    • C.
  • value_type β€” std::remove_cvref_t<std::tuple_element_t<N, ranges::range_value_t<Base>>>
  • difference_type β€” ranges::range_difference_t<Base>

πŸŽ€ Data members πŸŽ€

  • current_ (private) β€” an iterator of type ranges::iterator_t<Base> to current element of underlying sequence. (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 N^th tuple element (public member function)
  • operator[] (C++20) β€” accesses an element by index (public member function)
  • operator++, operator++(int), operator--, operator--(int), operator+=, operator-= (C++20) β€” advances or decrements the underlying iterator (public member function)

🌈 Non-member functions 🌈

  • operator==, operator<, operator>, operator<=, operator>=, operator<=> (C++20) β€” compares the underlying iterators (function)
  • operator+, operator- (C++20) β€” performs iterator arithmetic (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".

πŸ¦‹ See also πŸ¦‹

  • iterator (C++20) β€” the return type of ranges::transform_view::begin, and of ranges::transform_view::end when the underlying view is a common_range (private member class template).

πŸ’– source/version/date: http://cppreference.com Β· 2024.06.10 Β· footer page tag: std::ranges...w::iterator(3) β€” byeee bestie, go slay some iterators πŸ’…βœ¨

πŸ“¦ where this page comes from