std::ranges...view::begin(3)
okay bestie, welcome to the std::ranges...view::begin(3) page from the C++ Standard Libary manual π this is the std::ranges::cartesian_product_view::begin entry, and yes the name literally repeats itself, iconic.
β¨ NAME β¨
std::ranges::cartesian_product_view::begin β std::ranges::cartesian_product_view::begin π
π Synopsis π
constexpr iterator<false> begin()
(1) (since C++23)
requires (!__simple_view<First> || ... || !__simple_view<Vs>);
constexpr iterator<true> begin() const
requires (ranges::range<const First> && ... &&
(2) (since C++23)
ranges::range<const Vs>);
so there are two begin overloads, both constexpr, both since C++23 β¨ overload (1) has that requires (!__simple_view<First> || ... || !__simple_view<Vs>); constraint, and overload (2) is the const one with the requires (ranges::range<const First> && ... && ranges::range<const Vs>); situation π«Ά
Returns an iterator to the first element of the cartesian_product_view.
Let bases_ be the tuple of underlying views.
- Equivalent to
return /*iterator*/<false>(__tuple_transform(ranges::begin, bases_));. - Equivalent to
return /*iterator*/<true>(__tuple_transform(ranges::begin, bases_));.
π Parameters π
(none) β like, literally none. no parameters, no stress π«Ά
π Return value π
An iterator to the first element. periodt π
π 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{"Curiously"sv, "Recurring"sv,
"Template"sv, "Pattern"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&> first{*v.begin()};
std::cout << std::format("{}{}{}{}{}",
std::get<0>(first),
std::get<1>(first),
std::get<2>(first),
std::get<3>(first),
'\n');
}
β Output β
CRTP
it's giving CRTP and honestly that's the whole output π₯
π See also π
endβ returns an iterator or a sentinel to the end (C++23) (public member function)ranges::beginβ returns an iterator to the beginning of a range (C++20) (customization point object)
mwah π β this iconic page came from http://cppreference.com, dated 2024.06.10, and it's the std::ranges...view::begin(3) entry in the C++ Standard Libary manual. bye bestie π¦
π¦ 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