Boost logo

Boost :

Subject: Re: [boost] rvalue ref best practices?
From: Dave Abrahams (dave_at_[hidden])
Date: 2012-06-15 11:59:53


on Fri Jun 15 2012, Mathias Gaunard <mathias.gaunard-AT-ens-lyon.org> wrote:

> On 15/06/2012 06:42, Dave Abrahams wrote:
>>
>> on Tue Jun 12 2012, Mathias Gaunard<mathias.gaunard-AT-ens-lyon.org> wrote:
>>
>>> It is not natural for something written as foo = bar(); to change foo
>>> if bar fails.
>>
>> But you usually can't tell the difference between bar() failing and the
>> assignment failing, and it's perfectly natural for a failed assignment
>> to change the assignee.
>
> I can tell perfectly fine with
>
> T foo;
>
> try
> {
> foo = bar();
> }
> catch(...)
> {
> }

1. How can you tell whether bar failed or the assignment failed, here?
2. Do you really write code like that?

> // what state is foo in now?

Exactly my question.

-- 
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