Boost logo

Boost :

Subject: Re: [boost] rvalue ref best practices?
From: Sebastian Redl (sebastian.redl_at_[hidden])
Date: 2012-06-15 09:59:37


On 15.06.2012 14:36, Mathias Gaunard wrote:
> On 15/06/2012 06:42, Dave Abrahams wrote:
>> 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(...)
> {
> }
>
> // what state is foo in now?
Assume T is std::array<E, 32>, where E isn't movable and its copy
constructor/assignment might throw. std::array's assignment operator
gives only the basic guarantee. So if an exception occurred in the
assignment operator, you know that the vector is array, but you don't
know anything about its contents. It might be a wild mixture of what was
in it before the assignment and the elements returned from bar.

Sebastian


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk