26
Ranges library
[ranges]
26.7
Range adaptors
[range.adaptors]
26.7.23
Enumerate view
[range.enumerate]
26.7.23.1
Overview
[range.enumerate.overview]
1
#
enumerate_
view
is a view whose elements represent both the position and value from a sequence of elements
.
2
#
The name
views
::
enumerate
denotes a range adaptor object
.
Given a subexpression
E
, the expression
views
::
enumerate
(
E
)
is expression-equivalent to
enumerate_
view
<
views
::
all_
t
<
decltype
(
(
E
)
)
>
>
(
E
)
.
[
Example
1
:
vector
<
int
>
vec
{
1
,
2
,
3
}
;
for
(
auto
[
index, value
]
:
views
::
enumerate
(
vec
)
)
cout
<
<
index
<
<
":"
<
<
value
<
<
' '
;
// prints
0:1 1:2 2:3
—
end example
]