Files
2025-10-25 03:02:53 +03:00

1.5 KiB
Raw Permalink Blame History

[range.cartesian.overview]

25 Ranges library [ranges]

25.7 Range adaptors [range.adaptors]

25.7.33 Cartesian product view [range.cartesian]

25.7.33.1 Overview [range.cartesian.overview]

1

#

cartesian_product_view takes any non-zero number of ranges n and produces a view of tuples calculated by the n-ary cartesian product of the provided ranges.

2

#

The name views::cartesian_product denotes a customization point object ([customization.point.object]).

Given a pack of subexpressions Es, the expression views::cartesian_product(Es...) is expression-equivalent to

views::single(tuple()) if Es is an empty pack,

otherwise,cartesian_product_view<views::all_t<decltype((Es))>...>(Es...).

3

#

[Example 1: vector v { 0, 1, 2 };for (auto&& [a, b, c] : views::cartesian_product(v, v, v)) { cout << a << ' ' << b << ' ' << c << '\n';}// The above prints// 0 0 0// 0 0 1// 0 0 2// 0 1 0// 0 1 1// ... — end example]