26
Ranges library
[ranges]
26.7
Range adaptors
[range.adaptors]
26.7.11
Take while view
[range.take.while]
26.7.11.1
Overview
[range.take.while.overview]
1
#
Given a unary predicate
pred
and a view
r
,
take_
while_
view
produces a view of the range [
ranges
::
begin
(
r
)
, ranges
::
find_
if_
not
(
r, pred
)
)
.
2
#
The name
views
::
take_
while
denotes a range adaptor object (
[range.
adaptor.
object]
)
.
Given subexpressions
E
and
F
, the expression
views
::
take_
while
(
E, F
)
is expression-equivalent to
take_
while_
view
(
E, F
)
.
3
#
[
Example
1
:
auto
input
=
istringstream
{
"0 1 2 3 4 5 6 7 8 9"
}
;
auto
small
=
[
]
(
const
auto
x
)
noexcept
{
return
x
<
5
;
}
;
auto
small_ints
=
views
::
istream
<
int
>
(
input
)
|
views
::
take_while
(
small
)
;
for
(
const
auto
i
:
small_ints
)
{
cout
<
<
i
<
<
' '
;
// prints
0 1 2 3 4
}
auto
i
=
0
; input
>
>
i; cout
<
<
i;
// prints
6
—
end example
]