Boost logo

Boost :

From: Jeremy Maitin-Shepard (jbms_at_[hidden])
Date: 2003-05-04 20:29:09


On Sun, May 04, 2003 at 07:15:59PM -0400, Noel Yap wrote:
> I still don't understand. What's wrong with:
>
> ref< T > f(); // returns a reference to an uncopyable object, f owns
> the returned object
> T& p = f().get();

Assuming f is a function, rather than a method, the only way for f to
own this returned object is if it is a global variable. If you intend
that f is returning a dynamically allocated object, when and how will
this memory be deallocated?

> in place of:
>
> void f( out< T > p_ );
> T p;
> f( out( p ) );

Here, the callee, rather than f, owns the object. No dynamic
allocation needs to be used.

- Jeremy Maitin-Shepard


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