|
Boost : |
Subject: Re: [boost] rvalue ref best practices?
From: Dave Abrahams (dave_at_[hidden])
Date: 2012-06-16 00:24:10
on Fri Jun 15 2012, Mathias Gaunard <mathias.gaunard-AT-ens-lyon.org> wrote:
> On 15/06/2012 17:59, Dave Abrahams wrote:
>
>> 1. How can you tell whether bar failed or the assignment failed, here?
>
> If I know that T::operator= has the strong guarantee,
Big if. That wasn't part of the scenario you framed.
> I know that foo will always be in either of two states: either bar()
> succeeds, and it has the new value returned by bar(), or it failed,
> and it has the old value.
Yes, by definition.
> If overloading were allowed to take foo, half-modify it, then fail,
> then that wouldn't be true anymore.
>
>> 2. Do you really write code like that?
>
> Of course, what would be the point of exceptions is not to catch them?
Usually you want to do something with the exception once caught; your
code doesn't do that. And code where the catch block doesn't rethrow
tends to be incredibly rare.
-- Dave Abrahams BoostPro Computing http://www.boostpro.com
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk