Boost logo

Boost Users :

Subject: Re: [Boost-users] boost bind, issue moving from 1.57 to 1.60
From: Gavin Lambert (gavinl_at_[hidden])
Date: 2016-06-16 20:40:36

On 17/06/2016 12:27, Piotr Kowalski wrote:
> Under Visual Studio C++ 2013 the example works fine after adding a
> reference in function signature:
> boost::function<bool(boost::shared_ptr<const Boom>&)>
> This somehow prevents too much forwarding and losing the original value

I'm a firm believer in never ever passing smart pointers by value --
they're still objects and copying them is expensive and unnecessary when
accepting parameters. (You do have to pay for copying sometimes,
particularly when passing things between threads or deferred calls --
but in this case the bind itself will do the copy and you don't need to
copy it again when calling the bound method.)

Although it should be a const& parameter.

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at