boost::adaptors::filter
References
Headers
boost::adaptors::filter
is available by including
any of the following headers:
boost/range/adaptor/filtered.hpp
orboost/range/adaptors.hpp
Examples
filter-function.cpp
#include <iostream>
#include <vector>
#include <boost/range/adaptors.hpp>
const std::vector<int> vec = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
bool is_even(int n) {
return n % 2 == 0;
}
int main() {
std::cout << "vec filetered by is_even(): ";
for (int i : boost::adaptors::filter(vec, is_even)) {
std::cout << i << " ";
}
std::cout << std::endl;
return 0;
}
Output:
vec filetered by is_even(): 0 2 4 6 8
Boost Range for Humans
This reference is part of Boost Range for Humans. Click the link to the overview.