
On Monday 25 August 2003 10:21 pm, Darren Cook wrote:
Thanks for the reply. I can almost match that up to the parts in the while loop, except mention of "list" is missing. Should it be:
boost::bind(&Points::add, &list, boost::bind(&Info::key, boost::bind(&InfoContainer::get, &cs, _1))));
Yes, that's correct.
BTW, I was hoping I'd be able to do something like this: std::for_each(c->points.begin(),c->points.end(), list.add(cs.get( _1 )->key) );
This is why we want lambda support in the language :)
But after some experiments with boost::lambda I see why this isn't possible. I think if just one call to bind is possible then it is worth it, but when bind is required 2 or more times, falling back to a while loop or a functor seems better. Is anyone else using a similar guideline?
Darren
I still find the bind/lambda versions less error-prone than writing the equivalent (small) for/while loop, but I tend to put the lambda expression that I really want to write in a comment. Doug