Boost logo

Boost Users :

Subject: Re: [Boost-users] Annoying coding
From: Maxim Koshelev (chuchelo_at_[hidden])
Date: 2009-01-20 09:33:03


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_at_[hidden]> 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.


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net