Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- lambda with templates
- template <class in, class out, class T>
- out stransform(in b, in e, out d, T p(const T&)) {
- while (b != e)
- *d++ = p(*b++);
- return d;
- }
- stransform(begin(vec1), end(vec1), back_inserter(vec2), predi<double>);
- stransform(begin(vec1), end(vec1), back_inserter(vec2), [] (double x) ->double {return x * 10;} );
- template <class in, class out, class UnaryPredicate>
- out stransform(in b, in e, out d, UnaryPredicate p);
- stransform (
- begin (vec1),
- end (vec1),
- back_inserter (vec2),
- [] (const double & x) -> double {
- return x * 10;
- });
- template<class InputIterator, class OutputIterator, class Functor>
- OutputIterator
- transform(InputIterator begin, InputIterator end, OutputIterator out, Functor f);
- // function declaration
- int increment(int);
- int array[] = { 0, 1, 2, 3, 4 };
- transform(std::begin(array), std::end(array), std::begin(array), increment);
- template<typename InputIterator, typename OutputIterator, typename Functor>
- OutputIterator
- transform(InputIterator begin, InputIterator end, OutputIterator out, Functor f);
Add Comment
Please, Sign In to add comment