#
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..).
[Example 1: vector<int> 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]

Follow Lee on X/Twitter - Father, Husband, Serial builder creating AI, crypto, games & web tools. We are friends :) AI Will Come To Life!

Check out: eBank.nz (Art Generator) | Netwrck.com (AI Tools) | Text-Generator.io (AI API) | BitBank.nz (Crypto AI) | ReadingTime (Kids Reading) | RewordGame | BigMultiplayerChess | WebFiddle | How.nz | Helix AI Assistant