Boost logo

Boost :

From: David Abrahams (dave_at_[hidden])
Date: 2002-10-12 13:33:08


Terje Slettebø <tslettebo_at_[hidden]> writes:

> Again, Howard's reply shows convincingly that the RVO might in fact be
> prevented using the above code. However, according to Daniel's proposal, if
> a compiler implements NRVO, then the following might be optimised:
>
> friend T operator+( const T& lhs, const T& rhs )
> {
> T nrv( lhs );
> nrv += rhs;
> return nrv;
> }
>
> A note, also to Andrei's reply: I only asked why it's not done this way, for
> the points I brought up. I didn't say it should be done this way. The
> replies I got, that operating on a non-const may be useful, and that the
> above code may prevent optimisation, seems reasonable to me.

I agree.

> It's also good that this was brought up, as these points apparently
> were not well known.

I agree again. So thanks again for bringing it up!

-- 
           David Abrahams * Boost Consulting
dave_at_[hidden] * http://www.boost-consulting.com

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