Advertisement
Dzham

poeben

Jan 16th, 2018
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. #include <algorithm>
  2. #include <vector>
  3. #include <iostream>
  4.  
  5. using namespace std;
  6.  
  7. template <typename T>
  8. void print_results(T * first, T * last) {
  9. while (first != last) {
  10. cout << *first << ' ';
  11. first++;
  12. }
  13. }
  14.  
  15. template <typename T>
  16. void process(const vector<T>& data) {
  17. vector<T> result();
  18. typename vector<T>::iterator it;
  19. it = result.begin();
  20. T * filtered_last = copy_if(
  21. data.begin(),
  22. data.end(),
  23. it,
  24. [](const T& x) { return x > 0; }
  25. );
  26.  
  27. print_results(filtered, filtered_last);
  28. delete result;
  29. }
  30.  
  31. int main() {
  32. vector<int> r = { 1, 2, 3, -1, 5 };
  33. process(r);
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement