26
Ranges library
[ranges]
26.7
Range adaptors
[range.adaptors]
26.7.27
Adjacent view
[range.adjacent]
26.7.27.1
Overview
[range.adjacent.overview]
1
#
adjacent_
view
takes a view and produces a view whose
M
th
element is a tuple of references to 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
::
adjacent
<
N
>
denotes a range adaptor object (
[range.
adaptor.
object]
)
.
Given a subexpression
E
and a constant expression
N
, the expression
views
::
adjacent
<
N
>
(
E
)
is expressionequivalent to
(2.1)
(
(
void
)
E,
auto
(
views
::
empty
<
tuple
<
>
>
)
)
if
N
is equal to
0
,
(2.2)
otherwise,
adjacent_
view
<
views
::
all_
t
<
decltype
(
(
E
)
)
>
, N
>
(
E
)
.
[
Example
1
:
vector v
=
{
1
,
2
,
3
,
4
}
;
for
(
auto
i
:
v

views
::
adjacent
<
2
>
)
{
cout
<
<
"("
<
<
std
::
get
<
0
>
(
i
)
<
<
", "
<
<
std
::
get
<
1
>
(
i
)
<
<
") "
;
// prints
(1, 2) (2, 3) (3, 4)
}
—
end example
]
3
#
Define
REPEAT
(
T, N
)
as a pack of
N
types, each of which denotes the same type as
T
.