
29 May
2011
29 May
'11
4:41 a.m.
On Sun, May 29, 2011 at 12:09 AM, Lars Viklund <zao@acc.umu.se> 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