Go back to Richel Bilderbeek's homepage.

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

 

 

 

 

 

(C++) Boost.Lambda

 

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);
}

 

 

 

 

 

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

Go back to Richel Bilderbeek's homepage.

 

Valid XHTML 1.0 Strict