Boost logo

Boost :

From: Andrei Alexandrescu (andrewalex_at_[hidden])
Date: 2002-10-10 18:09:40


"David Abrahams" <dave_at_[hidden]> wrote in message
news:uadllzzd1.fsf_at_boost-consulting.com...
> "Andrei Alexandrescu" <andrewalex_at_[hidden]> writes:
>
> Oh, and by the way...
>
> > * Here are current state-of-the-art recommended canonic signatures and
> > implementations of some primitive functions:
> >
> > class T
> > {
> > ...
> > T& operator=(const T& rhs)
> > {
> > T copy(rhs);
> > rhs.swap(*this);
> > return *this;
> > }
> > };

By the way again :o), here there's an obvious typo in my original posting:
it's copy.swap, not rhs.swap.

> If you've been talking with Scott Meyers recently you might already
> know that I certainly agree about operator= for lots of reasons.

Cool. My point is, even when one wants to implement the copy-and-swap idiom,
the implementation above is the worst that could possibly be written.

Andrei


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