std::ranges...ator::next,(3)
NAME π
std::ranges::cartesian_product_view::iterator::next, -std::ranges::cartesian_product_view::iterator::next,
okay bestie, welcome to the std::ranges...ator::next,(3) page from the C++ Standard Libary manual π
this one is all about the exposition-only helpers hanging out inside std::ranges::cartesian_product_view::iterator, and yes we are getting into the recursive iterator sauce β¨
Synopsis π¦
the synopsis opens with this absolute unit of a signature:
std::ranges::cartesian_product_view<First, Vs...>::iterator<Const>::distance_from
/*next*/ β exposition only* π
template< std::size_t N = sizeof...(Vs) > (since C++23)
constexpr void /*next*/(); (exposition only*)
if you call it with the default template parameter, it recursively generates the next element (the tuple of iterators) in cartesian_product_view π«Ά
let current_ denote the underlying tuple of iterators. it's equivalent to:
auto& it = std::get<N>(current_);
++it;
if constexpr (N > 0)
{
if (it == ranges::end(std::get<N>(parent_->bases_)))
{
it = ranges::begin(std::get<N>(parent_->bases_));
next<N - 1>();
}
}
used in the following non-static member functions:
ranges::cartesian_product_view::operator+
/*prev*/ β exposition only* π
template< std::size_t N = sizeof...(Vs) > (since C++23)
constexpr void /*prev*/(); (exposition only*)
if you call it with the default template parameter, it recursively generates the previous element (the tuple of iterators) in cartesian_product_view π§
let current_ denote the underlying tuple of iterators. it's equivalent to:
auto& it = std::get<N>(current_);
if constexpr (N > 0)
{
if (it == ranges::begin(std::get<N>(parent_->bases_)))
{
it = /*cartesian-common-arg-
end*/(std::get<N>(parent_->bases_));
prev<N - 1>();
}
}
--it;
used in the following non-static member functions:
ranges::cartesian_product_view::operator-
/*distance_from*/ β exposition only* π
template< class Tuple >
(since C++23)
constexpr difference_type (exposition only*)
/*distance-from*/( const Tuple& t ) const;
returns the "distance" (i.e., number of "hops") between two iterators π¦
let:
parent_be the underlying pointer tocartesian_product_view/*scaled-size*/(N)be:- the product of
static_cast<difference_type>(ranges::size(std::get<N>(parent_->bases_)))and/*scaled-size*/(N + 1)ifN β€ sizeof...(Vs), otherwise static_cast<difference_type>(1);
- the product of
/*scaled-distance*/(N)be the product ofstatic_cast<difference_type>(std::get<N>(current_) - std::get<N>(t))and/*scaled-size*/(N + 1);/*scaled-sum*/be the sum of/*scaled-distance*/(N)for every integer0 β€ N β€ sizeof...(Vs).
returns: /*scaled-sum*/ β
the behavior is undefined if/*scaled-sum*/cannot be represented bydifference_typeβ that's UB, bestie, not a cute vibe ππ
used in the following functions:
operator-(const /*iterator*/&, const /*iterator*/&)operator-(const /*iterator*/&, std::default_sentinel_t)
Parameters πΈ
tβ a tuple of iterators to find the distance to
mwah π this little icon comes from http://cppreference.com, dated 2024.06.10, with the footer name std::ranges...ator::next,(3) β periodt, we ate and left no crumbs ππ
π¦ 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