std::ranges...w::iterator(3)
π¦ std::ranges...w::iterator(3) π¦
okay so this is from the C++ Standard Libary manual, section (3). The title is exactly std::ranges...w::iterator(3) β yes, the dots are doing their thing β and weβre about to get into std::ranges::filter_view::iterator with full bestie energy. π
β¨ NAME β¨
std::ranges::filter_view::iterator β literally std::ranges::filter_view::iterator. Thatβs the name, no cap.
π Synopsis π
class /*iterator*/; (since C++20)
(exposition only*)
The return type of filter_view::begin. Slay.
This is a bidirectional_iterator if V models bidirectional_range, a forward_iterator if V models forward_range, and input_iterator otherwise.
π¨ Modification of the element denoted by this iterator is permitted, but results in undefined behavior if the resulting value does not satisfy the filterβs predicate. Like, you can do it, but if the predicate says no and you changed the value anyway, thatβs UB, bestie. Be careful.
π Member types π
iterator_conceptβ one of:std::bidirectional_iterator_tag, ifVmodelsbidirectional_range,std::forward_iterator_tag, ifVmodelsforward_iterator,std::input_iterator_tagotherwise.
iterator_categoryβ defined if and only ifVmodelsforward_range. LetCbe the typestd::iterator_traits<ranges::iterator_t<V>>::iterator_category. Then:std::bidirectional_iterator_tag, ifCmodelsstd::derived_from<std::bidirectional_iterator_tag>,std::forward_iterator_tag, ifCmodelsstd::derived_from<std::forward_iterator_tag>,Cotherwise.
value_typeβranges::range_value_t<V>.difference_typeβranges::range_difference_t<V>.
πΈ Data members πΈ
current_(private) β an iterator of typeranges::iterator_t<V>into the underlying view.(exposition-only member object*)parent_(private) β a pointer of typeranges::filter_view<V, Pred>*to the parentfilter_viewobject.(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*,operator->(C++20) β forwards to the underlying iterator (public member function)operator++,operator++(int)(C++20) β advances the iterator (public member function)operator--,operator--(int)(C++20) β decrements the iterator (public member function)
π₯ std::ranges::filter_view::iterator::iterator π₯
/*iterator*/()
requires std::default_initializable<ranges::iterator_t<V>> = default;
constexpr /*iterator*/( filter_view& parent,
ranges::iterator_t<V> current );
- (since C++20) Initializes
current_andparent_with their default member initializers, which are= ranges::iterator_t<V>()and= nullptrrespectively. - (since C++20) Initializes
current_withstd::move(current)andparent_withstd::addressof(parent).
π¦ std::ranges::filter_view::iterator::base π¦
constexpr const ranges::iterator_t<V>& base() const & noexcept;
constexpr ranges::iterator_t<V> base() &&;
- (since C++20) Equivalent to
return current_;. - (since C++20) Equivalent to
return std::move(current_);.
π std::ranges::filter_view::iterator::operator*,-> π
constexpr ranges::range_reference_t<V> operator*() const;
constexpr ranges::iterator_t<V> operator->() const
requires /*has-arrow*/<ranges::iterator_t<V>> &&
std::copyable<ranges::iterator_t<V>>;
- (since C++20) Equivalent to
return *current_;. - (since C++20) Equivalent to
return current_;.
For a type I, /*has-arrow*/<I> is modeled or satisfied, if and only if I models or satisfies input_iterator respectively, and either I is a pointer type or requires(I i){ i.operator->();} is true.
β‘ std::ranges::filter_view::iterator::operator++ β‘
constexpr /*iterator*/& operator++();
constexpr void operator++( int );
constexpr /*iterator*/ operator++( int )
requires ranges::forward_range<V>;
- (since C++20) Equivalent to
current_ = ranges::find_if(std::move(++current_),
ranges::end(parent_->base_),
std::ref(*parent_->pred_));
return *this;
- (since C++20) Equivalent to
++*this;. - (since C++20) Equivalent to
auto tmp = *this; ++*this; return tmp;.
π std::ranges::filter_view::iterator::operator-- π
constexpr /*iterator*/& operator--()
requires ranges::bidirectional_range<V>;
constexpr /*iterator*/ operator--( int )
requires ranges::bidirectional_range<V>;
- (since C++20) Equivalent to
do
--current_;
while (!std::invoke(*parent_->pred_, *current_));
return *this;
- (since C++20) Equivalent to
auto tmp = *this; --*this; return tmp;.
π Non-member functions π
operator==(C++20) β compares the underlying iterators (function)iter_move(C++20) β casts the result of dereferencing the underlying iterator to its associated rvalue reference type (function)iter_swap(C++20) β swaps the objects pointed to by two underlying iterators (function)
π
operator==(std::ranges::filter_view::iterator) π
friend constexpr bool operator==( const /*iterator*/& x, const /*iterator*/& y )
requires std::equality_comparable<ranges::iterator_t<V>>;
(since C++20) Equivalent to return x.current_ == y.current_;.
The != operator is synthesized from operator==.
This function is not visible to ordinary unqualified or qualified lookup, and can only be found by argument-dependent lookup when std::ranges::filter_view::iterator is an associated class of the arguments.
π§ iter_move(std::ranges::filter_view::iterator) π§
friend constexpr ranges::range_rvalue_reference_t<V>
iter_move( const /*iterator*/& i )
noexcept(noexcept(ranges::iter_move(i.current_)));
(since C++20) Equivalent to return ranges::iter_move(i.current_);.
This function is not visible to ordinary unqualified or qualified lookup, and can only be found by argument-dependent lookup when std::ranges::filter_view::iterator is an associated class of the arguments.
π iter_swap(std::ranges::filter_view::iterator) π
friend constexpr void iter_swap( const /*iterator*/& x, const /*iterator*/& y )
noexcept(noexcept(ranges::iter_swap(x.current_, y.current_)))
requires std::indirectly_swappable<ranges::iterator_t<V>>;
(since C++20) Equivalent to ranges::iter_swap(x.current_, y.current_).
This function is not visible to ordinary unqualified or qualified lookup, and can only be found by argument-dependent lookup when std::ranges::filter_view::iterator is an associated class of the arguments.
π©Ή Defect reports π©Ή
The following behavior-changing defect reports were applied retroactively to previously published C++ standards.
P2259R1β applied toC++20; behavior as published: member typeiterator_categorywas always defined; correct behavior: defined only ifVis aforward_range.LWG 3533β applied toC++20; behavior as published: theconst&overload ofbasecopied the underlying iterator; correct behavior: returns a reference to it.LWG 3593β applied toC++20; behavior as published: theconst&overload ofbasemight not benoexcept; correct behavior: madenoexcept.
π bestie, thatβs the whole page. Source/version/date check: http://cppreference.com, 2024.06.10, and this is std::ranges...w::iterator(3). Bye, love you, go slay some ranges. π«Ά
π¦ 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