std::ranges...t_view::end(3)
π std::ranges::cartesian_product_view::end π
okay so this page is straight outta the C++ Standard Libary manual, and the page itself calls her std::ranges...t_view::end(3). yes, the header truncates the name like that. we move.
πΈ NAME πΈ
std::ranges::cartesian_product_view::end β std::ranges::cartesian_product_view::end
(yes, the NAME section is literally her name twice. iconic behavior. π )
β¨ SYNOPSIS β¨
okay bestie, here are the three overloads, and theyβre all since C++23. the (1), (2), and (3) bits are overload labels, not part of the C++ syntax vibe check.
constexpr iterator<false> end()
requires ((!__simple_view<First> || ... || !__simple_view<Vs>)
(1) (since C++23)
&&
__cartesian_product_is_common<First, Vs...>);
constexpr iterator<true> end() const
requires __cartesian_product_is_common<const First, const
(2) (since C++23)
Vs...>;
constexpr std::default_sentinel_t end() const noexcept;
(3) (since C++23)
π«Ά DESCRIPTION π«Ά
Returns an iterator or a sentinel representing the end of the cartesian_product_view. thatβs the whole plot, bestie.
Let bases_ be the underlying tuple of views.
π 1,2) the iterator overloads
Let:
__is_constbetruefor the const-qualified overload, andfalseotherwise;__is_emptybetrueif the expressionranges::empty(rng)istruefor anyrngamong the underlying ranges except the first one, andfalseotherwise; and__begin_or_first_end(rng)be expression-equivalent to__is_empty ? ranges::begin(rng) : __cartesian_common_arg_end(rng)ifrngis the first underlying range andranges::begin(rng)otherwise.
Equivalent to:
auto check = [](auto& rng) { return __begin_or_first_end(rng); };
return iterator<__is_const>(__tuple_transform(check, bases_));
π 3) the sentinel overload
Equivalent to: return std::default_sentinel;.
π PARAMETERS π
(none) β literally no parameters, bestie. none. zero. the void is the vibe. π«₯
π¦ RETURN VALUE π¦
An iterator to the element following the last element, or a sentinel which compares equal to the end iterator.
π EXAMPLE π
Run this code π
#include <array>
#include <format>
#include <iostream>
#include <ranges>
#include <string_view>
#include <tuple>
using namespace std::literals;
int main()
{
constexpr auto a = std::array{ "bool"sv, "goto"sv, "extern"sv,
"long"sv }; /*
^ ^ ^
^ */
constexpr auto v = std::ranges::cartesian_product_view(a[0], a[1], a[2], a[3]);
constexpr std::tuple<char const&,
char const&,
char const&,
char const&> last{*(v.end() - 1)};
std::cout << std::format("{}{}{}{}{}",
std::get<0>(last),
std::get<1>(last),
std::get<2>(last),
std::get<3>(last), '\n');
}
π OUTPUT π
long
π SEE ALSO π
beginβ returns an iterator to the beginning; (C++23) (public member function)ranges::endβ returns a sentinel indicating the end of a range; (C++20) (customization point object)
okay thatβs the whole page, bestie. source/version/date tea: http://cppreference.com, 2024.06.10, and the footer page is std::ranges...t_view::end(3). mwah πβ¨
π¦ 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