forked from boostorg/utility
small edit
[SVN r9151]
This commit is contained in:
@@ -10,6 +10,7 @@
|
|||||||
|
|
||||||
#include <boost/config.hpp>
|
#include <boost/config.hpp>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include <functional>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <boost/iterator_adaptors.hpp>
|
#include <boost/iterator_adaptors.hpp>
|
||||||
|
|
||||||
@@ -22,7 +23,7 @@ int main()
|
|||||||
int numbers[] = { 0, -1, 4, -3, 5, 8, -2 };
|
int numbers[] = { 0, -1, 4, -3, 5, 8, -2 };
|
||||||
const int N = sizeof(numbers)/sizeof(int);
|
const int N = sizeof(numbers)/sizeof(int);
|
||||||
|
|
||||||
// Example using make_filter_iterator
|
// Example using make_filter_iterator()
|
||||||
std::copy(boost::make_filter_iterator<is_positive_number>(numbers, numbers + N),
|
std::copy(boost::make_filter_iterator<is_positive_number>(numbers, numbers + N),
|
||||||
boost::make_filter_iterator<is_positive_number>(numbers + N, numbers + N),
|
boost::make_filter_iterator<is_positive_number>(numbers + N, numbers + N),
|
||||||
std::ostream_iterator<int>(std::cout, " "));
|
std::ostream_iterator<int>(std::cout, " "));
|
||||||
@@ -38,6 +39,14 @@ int main()
|
|||||||
std::copy(filter_iter_first, filter_iter_last, std::ostream_iterator<int>(std::cout, " "));
|
std::copy(filter_iter_first, filter_iter_last, std::ostream_iterator<int>(std::cout, " "));
|
||||||
std::cout << std::endl;
|
std::cout << std::endl;
|
||||||
|
|
||||||
|
// Another example using make_filter_iterator()
|
||||||
|
std::copy(boost::make_filter_iterator(numbers, numbers + N,
|
||||||
|
std::bind2nd(std::greater<int>(), -2)),
|
||||||
|
boost::make_filter_iterator(numbers + N, numbers + N,
|
||||||
|
std::bind2nd(std::greater<int>(), -2)),
|
||||||
|
std::ostream_iterator<int>(std::cout, " "));
|
||||||
|
std::cout << std::endl;
|
||||||
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user