Go back to Richel Bilderbeek's homepage.
Go back to Richel Bilderbeek's C++ page.
std::plus is a functor that encapsulates operator+.
#include <vector> #include <algorithm> #include <numeric> const std::vector<int> AddTwo(const std::vector<int>& v) { std::vector<int> v_new; std::transform(v.begin(),v.end(),std::back_inserter(v_new), std::bind2nd(std::plus<int>(),2)); return v_new; }