Go back to Richel Bilderbeek's homepage.

Go back to Richel Bilderbeek's C++ page.

 

 

 

 

 

(C++) std::plus

 

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;
}

 

 

 

 

 

Go back to Richel Bilderbeek's C++ page.

Go back to Richel Bilderbeek's homepage.

 

Valid XHTML 1.0 Strict