How to Pass Class Member Functions to STL Algorithms
The C++ standard library makes it easy to use free functions with its STL algorithms. For example, with std::transform, we can write code like this: auto const inputs = std::vector<int>{1, 2, 3, 4, 5}; auto const results = std::vector<int>{}; std::transform(begin(inputs), end(inputs), back_inserter(results), myFunction); This has the effect of calling myFunction on each element of inputs and putting […]