25
Ranges library
[ranges]
25.7
Range adaptors
[range.adaptors]
25.7.31
Chunk by view
[range.chunk.by]
25.7.31.1
Overview
[range.chunk.by.overview]
1
#
chunk_
by_
view
takes a view and a predicate, and splits the view into
subrange
s between each pair of adjacent elements for which the predicate returns
false
.
2
#
The name
views
::
chunk_
by
denotes a range adaptor object (
[range.
adaptor.
object]
)
.
Given subexpressions
E
and
F
, the expression
views
::
chunk_
by
(
E, F
)
is expression-equivalent to
chunk_
by_
view
(
E, F
)
.
[
Example
1
:
vector v
=
{
1
,
2
,
2
,
3
,
0
,
4
,
5
,
2
}
;
for
(
auto
r
:
v
|
views
::
chunk_by
(
ranges
::
less_equal
{
}
)
)
{
cout
<
<
'['
;
auto
sep
=
""
;
for
(
auto
i
:
r
)
{
cout
<
<
sep
<
<
i; sep
=
", "
;
}
cout
<
<
"] "
;
}
// The above prints
[1, 2, 2, 3] [0, 4, 5] [2]
—
end example
]