Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <vector>
- #include <functional>
- template<typename T, typename F>
- void myapply(T begin, T end, F func)
- {
- for (auto i = begin; i != end; i++) {
- func(*i);
- }
- }
- template<typename T, typename F>
- std::vector<std::reference_wrapper<typename std::iterator_traits<T>::value_type>> myfilter2(T begin, T end, F func)
- {
- std::vector<std::reference_wrapper<typename std::iterator_traits<T>::value_type>> tmp;
- for (auto &i = begin; i != end; i++) {
- if (func(*i)) {
- tmp.push_back(*i);
- }
- }
- return tmp;
- }
Advertisement
Add Comment
Please, Sign In to add comment