Boost logo

Boost :

Subject: Re: [boost] Improving the assignment operators of various Boosttypes
From: David Abrahams (dave_at_[hidden])
Date: 2008-09-11 10:03:22


on Thu Sep 11 2008, Joel Falcou <joel.falcou-AT-u-psud.fr> wrote:

> David Abrahams a écrit :
>> Swapping and taking the parameter by value are orthogonal issues; the
>> latter has only to do with copy elision and not with exception safety.
>> Please see this thread:
>>
> http://groups.google.com/group/comp.lang.c++.moderated/browse_frm/thread/97ad5390e34d63a9/ef6b55d24b512070>
>
> Very interesting article. So my question is - as a teacher - what techniques
> should I teach to my student and with which justification ?

  self& operator=(self x) { swap(*this,x); return *this; }

with the rationale given in
http://groups.google.com/group/comp.lang.c++.moderated/msg/5e6014446d559b63
(I suspect Andrei's CUJ article is equally good or better but much
longer)

...but I would think given the thread mentioned above that answer would
be self-evident, so it makes me wonder if you're trying to ask something
else.

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