|
Boost : |
Subject: Re: [boost] [shared_ptr] calling functions by reference
From: Sid Sacek (ssacek_at_[hidden])
Date: 2011-05-30 21:23:02
Thank you. I appreciated all of the insight from all.
-----Original Message-----
From: boost-bounces_at_[hidden] [mailto:boost-bounces_at_[hidden]] On Behalf Of Olaf van der Spek
Sent: Sunday, May 29, 2011 7:06 AM
To: boost_at_[hidden]
Subject: Re: [boost] [shared_ptr] calling functions by reference
On Sun, May 29, 2011 at 4:36 AM, Sid Sacek <ssacek_at_[hidden]> wrote:
> This might be a unimportant question and may have already been answered many times before, but I was wondering about functions that take shared pointers as arguments. Is there ever a reason I would not want to use a shared_ptr reference as an argument? I can't think of any, but is there any?
Yes, I think. If the function makes a copy of the argument, passing by
value might allow you to take advantage of move semantics (if the
callee doesn't need the argument anymore), whereas passing by (const)
reference doesn't.
Olaf
_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk