(Note that if the first source sequence of cartesian_product is empty, then all four assertions pass as expected. This only shows up if the first source is non-empty, but one of the other sources is empty.)
The specification for C++23 cartesian_product_view::end() handles this by returning (in Flux terms) tuple{first(base0), first(base1), ...} if any base (from index 1 up) is empty, and tuple{last(base0), first(base1), ...} otherwise. At the moment, we unconditionally return the latter in cartesian_product_adaptor::last(), but we should change this to match the ranges behaviour.
Given
then
https://flux.godbolt.org/z/ocMKarfvx
(Note that if the first source sequence of
cartesian_product
is empty, then all four assertions pass as expected. This only shows up if the first source is non-empty, but one of the other sources is empty.)The specification for C++23
cartesian_product_view::end()
handles this by returning (in Flux terms)tuple{first(base0), first(base1), ...}
if any base (from index 1 up) is empty, andtuple{last(base0), first(base1), ...}
otherwise. At the moment, we unconditionally return the latter incartesian_product_adaptor::last()
, but we should change this to match the ranges behaviour.