Go back to Richel Bilderbeek's homepage.

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

 

 

 

 

 

(C++) std::divides

 

std::divides is a functor that encapsulates operator/. The functor to perform a multiplication on a range is std::multiplies.

 

 

 

 

 

Example

 

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

//From http://www.richelbilderbeek.nl/CppHalve.htm
void Halve(std::vector<double>& v)
{
  std::transform(v.begin(),v.end(),v.begin(),
    std::bind2nd(std::divides<double>(),2.0));
}

 

 

 

 

 

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

Go back to Richel Bilderbeek's homepage.

 

Valid XHTML 1.0 Strict