std::ranges::cartesian_product_view<First, Vs...>::begin
来自cppreference.com
< cpp | ranges | cartesian product view
constexpr iterator<false> begin() requires (!/*simple-view*/<First> || ... || !/*simple-view*/<Vs>); |
(1) | (C++23 起) |
constexpr iterator<true> begin() const requires (ranges::range<const First> && ... && ranges::range<const Vs>); |
(2) | (C++23 起) |
返回指向 cartesian_product_view
首元素的迭代器。
令 bases_
为各底层视图的元组。
1) 等价于 return /*iterator*/<false>(
tuple-transform
(ranges::begin, bases_));。2) 等价于 return /*iterator*/<true>(
tuple-transform
(ranges::begin, bases_));。参数
(无)
返回值
指向首元素的迭代器。
示例
运行此代码
#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'); }
输出:
CRTP
参阅
返回 指向末尾的迭代器或哨位 (公开成员函数) | |
(C++20) |
返回指向范围起始的迭代器 (定制点对象) |