26
Ranges library
[ranges]
26.7
Range adaptors
[range.adaptors]
26.7.32
Cartesian product view
[range.cartesian]
26.7.32.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
(2.1)
views
::
single
(
tuple
(
)
)
if
Es
is an empty pack,
(2.2)
otherwise,
cartesian_
product_
view
<
views
::
all_
t
<
decltype
(
(
Es
)
)
>
.
.
.
>
(
Es
.
.
.
)
.
3
#
[
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
]