From bf3540bc9c9f3d230c4d1ee58d6c8d5e7de969a0 Mon Sep 17 00:00:00 2001 From: tcbrindle Date: Thu, 14 Mar 2024 15:33:27 +0000 Subject: [PATCH] Update single header --- single_include/flux.hpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/single_include/flux.hpp b/single_include/flux.hpp index 943284a1..0ef0bbc1 100644 --- a/single_include/flux.hpp +++ b/single_include/flux.hpp @@ -5177,9 +5177,20 @@ struct cartesian_traits_base_impl { static constexpr auto last(Self& self) -> cursor_t requires cartesian_is_bounded { - auto cur = first(self); - std::get<0>(cur) = flux::last(get_base<0>(self)); - return cur; + if constexpr (CartesianKind == cartesian_kind::product) { + auto cur = first(self); + bool any_is_empty = std::apply([](auto& /*ignored*/, auto&... bases) { + return (flux::is_empty(bases) || ...); + }, self.bases_); + if (!any_is_empty) { + std::get<0>(cur) = flux::last(get_base<0>(self)); + } + return cur; + } else { + auto cur = first(self); + std::get<0>(cur) = flux::last(get_base<0>(self)); + return cur; + } } template