Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <algorithm>
- #include <vector>
- #include <iostream>
- using namespace std;
- template <typename T>
- void print_results(T * first, T * last) {
- while (first != last) {
- cout << *first << ' ';
- first++;
- }
- }
- template <typename T>
- void process(const vector<T>& data) {
- vector<T> result();
- typename vector<T>::iterator it;
- it = result.begin();
- T * filtered_last = copy_if(
- data.begin(),
- data.end(),
- it,
- [](const T& x) { return x > 0; }
- );
- print_results(filtered, filtered_last);
- delete result;
- }
- int main() {
- vector<int> r = { 1, 2, 3, -1, 5 };
- process(r);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement