(C++) Boost.Lambda
August 17, 2019 · View on GitHub
Boost.Lambda is a Boost library to allow for lambda expressions to replace for-loops or to simplify their corresponding algorithm.
#include <algorithm> #include <boost/lambda/lambda.hpp> //From http://www.richelbilderbeek.nl/CppTriple.htm template <class Container> void Triple(Container& c) { std::for_each(c.begin(),c.end(),boost::lambda::_1*=3); } #include <vector> #include <cassert> int main() { std::vector<int> v; v.push_back(1); Triple(v); assert(v[0]==3); }