|
Boost : |
From: Noel Yap (Noel.Yap_at_[hidden])
Date: 2003-04-24 06:31:35
Terje Slettebø wrote:
> The compiler may elide such copy, even if the temporary being returned is a
> named variable, and several compilers (such as g++ and the EDG based ones),
> does this optimisation (RVO). For example:
>
> <snip/>
Playing devil's advocate, I think RVO can easily be fooled with
not-so-tricky code. If you're really concerned about this situation,
use some sort of smart pointer. For example:
boost:shared_ptr< T > f( boost::shared_ptr< T > const in_ );
Noel
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk