Go back to Richel Bilderbeek's homepage.

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

 

 

 

 

 

(C++) std::minus

 

std::minus is a functor that encapsulates operator-.

 

#include <vector>
#include <algorithm>
#include <numeric>

const std::vector<int> MinusTwo(const std::vector<int>& v)
{
  std::vector<int> v_new;
  std::transform(v.begin(),v.end(),std::back_inserter(v_new),
    std::bind2nd(std::minus<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