|
Boost : |
Subject: Re: [boost] [shared_ptr] calling functions by reference
From: Matt Calabrese (rivorus_at_[hidden])
Date: 2011-05-29 00:41:03
On Sun, May 29, 2011 at 12:09 AM, Lars Viklund <zao_at_[hidden]> wrote:
>
> I've had real-life bugs of this kind. It's not pretty. Unless you have a
> genuine reason to access the same instance, try to avoid passing it by
> reference-to-non-const. If you feel you need to avoid the non-free
> copying cost, pass it by reference-to-const.
Passing by reference to const generally does not solve all problems either.
In both cases, it's still perfectly valid for other contexts to already hold
the object directly or by reference to non-const and for the value to be
modified via side-effects of further function calls.
-- -Matt Calabrese
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk