std::ranges...ew::iterator(3)
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>ifConstistrue, otherwiseranges::transform_view<V, F>. (exposition-only member type*)Base(private) βconst VifConstistrue, otherwiseV. (exposition-only member type*)iterator_conceptβ the tag depends onBase:std::random_access_iterator_tagifBasemodelsrandom_access_range,std::bidirectional_iterator_tagifBasemodelsbidirectional_range,std::forward_iterator_tagifBasemodelsforward_range,std::input_iterator_tagotherwise.
iterator_categoryβ the rules are:- Not defined if
Basedoes not modelforward_range. - Otherwise, if
std::invoke_result_t<F&, ranges::range_reference_t<Base>>is not a reference,std::input_iterator_tag. - Else, let
Cbestd::iterator_traits<ranges::iterator_t<Base>>::iterator_category. IfCisstd::contiguous_iterator_tag, the type isstd::random_access_iterator_tag; otherwise, the type isC.
- Not defined if
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 parenttransform_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: memberiterator_categoryis always defined. Correct behavior: defined only ifBasemodelsforward_range.LWG 3555β applied to C++20. Behavior as published: the definition ofiterator_conceptignoresconst. Correct behavior: made to considerconst.LWG 3798β applied to C++20. Behavior as published:iterator_categoryis 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
- nixpkgs unstable: stdman 2024.07.05
- opensuse-leap 16.0: stdman 2024.07.05-bp160.1.9 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms