
20 Jan
2009
20 Jan
'09
2:33 p.m.
But I think that boost::bind wait function as first parameter, not constant. Or I'm wrong? On Tue, Jan 20, 2009 at 5:21 PM, Alan M. Carroll <amc@network-geographics.com> wrote:
Why not use Boost.Bind? It will bind to data members, returning a functor that accesses that member. E.g.
boost::bind(&A::a, _1);
will create a functor that takes an instance of A and returns a reference to the a member. You can then pass that to whatever other functor is being used. Something like (not tested!)
std::accumulate(m.begin(), m.end(), bind(std::add, _1, bind(&std::map<std::string, int>::value_type::first, _1));
Boost.Lambda can do this as well, but I am not familiar enough with it to provide an example.