Boost logo

Boost :

From: Terje Slettebø (tslettebo_at_[hidden])
Date: 2002-10-14 16:13:23

>From: "Andrei Alexandrescu" <andrewalex_at_[hidden]>

> I need to mollify my arguments against the lying const. But only a bit!
> operator+ example shows that many compilers prefer const T& as the first
> argument in certain cases. However, in the case of assignment:
> T& operator=(const T& src)
> {
> T copy(src);
> copy.swap(*this);
> return *this;
> }
> versus:
> T& operator=(T src)
> {
> src.swap(*this);
> return *this;
> }
> I'd be quite surprised of the compiler could go past the const in the
> argument.

I'm not sure what you mean, here. In both cases, it needs to make a copy. I
ran a quick test on the above, and at least on Intel C++, both made just one
copy. Could you elaborated on what you mean?

> P.S. The interest in ZUTO is staggering. The number of volunteering
> reviewers has hit 70. If I made any mistake, I'm toast!!! :o)

Please add me to the list. :)

I could also do tests on various compilers, for it.



Boost list run by bdawes at, gregod at, cpdaniel at, john at