(C++) std::divides
January 11, 2018 · View on GitHub
(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)); }