std::ranges...ew::iterator(3)
π«Ά NAME
std::ranges::split_view::iterator β std::ranges::split_view::iterator
okay so bestie, welcome to the std::ranges...ew::iterator(3) page in the C++ Standard Libary manual π yes, thatβs the exact manual-name energy, typo and all. This page is literally all about the iterator type for split_view, and itβs giving very niche-but-iconic C++ lore. π
β¨ Synopsis β¨
class /*iterator*/; (since C++20)
(exposition only*)
The return type of split_view::begin. This is a forward_iterator, so it is expected that V models at least forward_range. π¦
π Member types
iterator_conceptβstd::forward_iterator_tagiterator_categoryβstd::input_iterator_tagvalue_typeβranges::subrange<ranges::iterator_t<V>>difference_typeβranges::range_difference_t<V>
π§ Data members
parent_(private) β A pointer of typeranges::split_view<V, Pattern>*to the parentsplit_viewobject. (exposition-only member object*)cur_(private) β An iterator of typeranges::iterator_t<V>into the underlying view that points to the begin of a current subrange. (exposition-only member object*)next_(private) β A subrange of typeranges::subrange<ranges::iterator_t<V>>to the position of the pattern next to the current subrange. (exposition-only member object*)trailing_empty_(private) β A boolean flag that indicates whether an empty trailing subrange (if any) was reached. (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) β returns the current subrange (public member function)operator++(C++20) β advances the iterator (public member function)operator++(int)(C++20) β public member function
πΈ std::ranges::split_view::iterator::iterator
/*iterator*/() = default; (1) (since C++20)
constexpr /*iterator*/( split_view& parent, ranges::iterator_t<V> current,
ranges::subrange<ranges::iterator_t<V>> next ); (2) (since C++20)
- Value-initializes non-static data members with their default member initializers, that is
ranges::split_view* parent_ = nullptr;,ranges::iterator_t<V> cur_ = ranges::iterator_t<V>();,ranges::subrange<ranges::iterator_t<V>> next_ = ranges::subrange<ranges::iterator_t<V>>();, andbool trailing_empty_ = false;.
- Initializes non-static data members:
ranges::split_view* parent_ = std::addressof(parent);,ranges::iterator_t<V> cur_ = std::move(current);,ranges::subrange<ranges::iterator_t<V>> next_ = std::move(next);, andbool trailing_empty_ = false;.
π¦ std::ranges::split_view::iterator::base
constexpr const ranges::iterator_t<V> base() const; (since C++20)
Equivalent to return cur_;. π
β std::ranges::split_view::iterator::operator*
constexpr ranges::range_reference_t<V> operator*() const; (since C++20)
Equivalent to return {cur_, next_.begin()};. β¨
π₯ std::ranges::split_view::iterator::operator++
constexpr /*iterator*/& operator++(); (1) (since C++20)
constexpr void operator++( int ); (2) (since C++20)
- Equivalent to
cur_ = next_.begin();
if (cur_ != ranges::end(parent_->base_))
{
if (cur_ = next_.end(); cur_ == ranges::end(parent_->base_))
{
trailing_empty_ = true;
next_ = {cur_, cur_};
}
else
next_ = parent_->find_next(cur_);
}
else
trailing_empty_ = false;
return *this;
- Equivalent to
auto tmp = *this; ++*this; return tmp;. π
π Non-member functions
operator==(C++20) β compares the underlying iterators (function)
π operator==(std::ranges::split_view::iterator, std::ranges::split_view::iterator)
friend constexpr bool operator==( const /*iterator*/& x, const /*iterator*/& y ); (since C++20)
Equivalent to return x.cur_ == y.cur_ and x.trailing_empty_ == y.trailing_empty_;.
The != operator is synthesized from operator==. no cap, thatβs the whole vibe check π«Ά
This function is not visible to ordinary unqualified or qualified lookup, and can only be found by argument-dependent lookup when std::ranges::split_view::iterator is an associated class of the arguments.
π thatβs the page, bestie β source: http://cppreference.com Β· version/date: 2024.06.10 Β· page: std::ranges...ew::iterator(3). mwah, 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