Boost logo

Boost :

From: Daniel Frey (d.frey_at_[hidden])
Date: 2005-04-28 13:55:02


Søren Lassen wrote:
> The standard places some limits on when NAMED objects may be optimized
> away. From this follows implicitly that UNNAMED objects may always be
> optimized away. Or, to quote from Scott Meyers' "More Effective C++",
> page 109-110: "However, the fact remains that unnamed objects have

BTW, did you read Scott's errata? To quote from it:

109 Both the first and second implementations on this page
      suffer from the problem that they are returning whatever
      operator=+ returns. In general, there is no way to know
      what this is (yes, it's a reference to an object of type T,
      but a reference to which T object?), hence no way for
      compilers to optimize away the copy to operator+'s return
      value. The way to write operator+ such that the return
      value optimization can be performed is with this body:

        T result(lhs);
        result += rhs;
        return result.

taken from <http://www.aristeia.com/BookErrata/mec++-errata_frames.html>

Regards, Daniel


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