25
Ranges library
[ranges]
25.7
Range adaptors
[range.adaptors]
25.7.8
Filter view
[range.filter]
25.7.8.1
Overview
[range.filter.overview]
1
#
filter_
view
presents a view of the elements of an underlying sequence that satisfy a predicate
.
2
#
The name
views
::
filter
denotes a range adaptor object (
[range.
adaptor.
object]
)
.
Given subexpressions
E
and
P
, the expression
views
::
filter
(
E, P
)
is expression-equivalent to
filter_
view
(
E, P
)
.
3
#
[
Example
1
:
vector
<
int
>
is
{
0
,
1
,
2
,
3
,
4
,
5
,
6
}
;
auto
evens
=
views
::
filter
(
is,
[
]
(
int
i
)
{
return
0
=
=
i
%
2
;
}
)
;
for
(
int
i
:
evens
)
cout
<
<
i
<
<
' '
;
// prints
0 2 4 6
—
end example
]