25
Ranges library
[ranges]
25.7
Range adaptors
[range.adaptors]
25.7.30
Slide view
[range.slide]
25.7.30.1
Overview
[range.slide.overview]
1
#
slide_
view
takes a view and a number
N
and produces a view whose
M
th
element is a view over the
M
th
through
(
M
+
N
−
1
)
th
elements of the original view
.
If the original view has fewer than
N
elements, the resulting view is empty
.
2
#
The name
views
::
slide
denotes a range adaptor object (
[range.
adaptor.
object]
)
.
Given subexpressions
E
and
N
, the expression
views
::
slide
(
E, N
)
is expression-equivalent to
slide_
view
(
E, N
)
.
[
Example
1
:
vector v
=
{
1
,
2
,
3
,
4
}
;
for
(
auto
i
:
v
|
views
::
slide
(
2
)
)
{
cout
<
<
'['
<
<
i
[
0
]
<
<
", "
<
<
i
[
1
]
<
<
"] "
;
// prints
[1, 2] [2, 3] [3, 4]
}
—
end example
]