On this page
std::ranges::cartesian_product_view<First, Vs...>::end
|
(1) | (since C++23) |
|
(2) | (since C++23) |
|
(3) | (since C++23) |
Returns an iterator or a sentinel representing the end of the cartesian_product_view
.
Let bases_
be the underlying tuple of views.
__is_const
betrue
for the const-qualified overload, andfalse
otherwise;__is_empty
betrue
if the expressionranges::empty(rng)
istrue
for anyrng
among the underlying ranges except the first one andfalse
otherwise; and__begin_or_first_end(rng)
be expression-equivalent to__is_empty ? ranges::begin(rng) : __cartesian_common_arg_end(rng)
ifrng
is 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) Equivalent to:
return std::default_sentinel;
.
Parameters
(none)
Return value
An iterator to the element following the last element, or a sentinel which compares equal to the end iterator.
Example
#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
(C++23)
|
returns an iterator to the beginning (public member function) |
(C++20)
|
returns a sentinel indicating the end of a range (customization point object) |
© cppreference.com
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
https://en.cppreference.com/w/cpp/ranges/cartesian_product_view/end