Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- using namespace std;
- template<typename T>
- void Set(vector<T>& _vec, bool(*_filter)(T&), void(*_accumulator)(T&))
- {
- for (T& value : _vec)
- {
- if (!_filter(value)) continue;
- _accumulator(value);
- }
- };
- int main()
- {
- vector<float> vec = {5, 6, 7, 8, 9, 1, 2, 3};
- Set<float>(vec, [](float &a) { return a < 7; }, [](float &a) { a+=10;} );
- for (float& val : vec)
- cout << val << " ";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement