Go back to Richel Bilderbeek's homepage.
Go back to Richel Bilderbeek's C++ page.
Predicate to perform operator== on two values.
std::equal_to works better on int than on double, because of rounding errors. fuzzy_equal_to can be used for testing two double for equality with some tolerance.
The code below shows how to replace values that are equal to a zero by a one. Note: this is not a preferred version of ReplaceZeroByOne.
#include <vector> |
#include <algorithm> |
Go back to Richel Bilderbeek's C++ page.
Go back to Richel Bilderbeek's homepage.