Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2002-06-19 05:37:14

From: "David B. Held" <dheld_at_[hidden]>
> When passing the result of bind() to a function, is it advisable to
> pass by value or const&? Like so:
> template <class F>
> void Foo::Bar(F f) // const& better?
> {
> for_each(v.begin(), v.end(), f);
> }
> Bar(bind(&my_func, _1));

It's pretty much a matter of taste. The standard library uses pass by value
everywhere; function objects are typically cheap to copy. Passing by const
ref avoids a copy, but doesn't let you pass functions directly (you'll need
to use &my_func instead of my_func.)

Boost list run by bdawes at, gregod at, cpdaniel at, john at