Go back to Richel Bilderbeek's homepage.

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

 

 

 

 

 

(C++) boost::mem_fn

 

boost::mem_fn is an adapter, intended to be more flexible than STL adapters like std::mem_fun and std::mem_fun_ref.

 

boost::mem_fn can often replace both std::mem_fun and std::mem_fun_ref.

 

 

 

 

 

Example

 

#include <algorithm>
#include <numeric>
#include <vector>
#include <boost/shared_ptr.hpp>

struct Widget
{
  void DoIt() const { /* do it */ }
};

void DoIt(const std::vector<boost::shared_ptr<Widget> >& v)
{
  std::for_each(v.begin(),v.end(),boost::mem_fn(&Widget::DoIt));
}

 

 

 

 

 

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

Go back to Richel Bilderbeek's homepage.

 

Valid XHTML 1.0 Strict