Smart pointers instead of GC?

Frank Bauer y at z.com
Sat Feb 1 22:00:20 PST 2014


On Sunday, 2 February 2014 at 05:41:53 UTC, Andrei Alexandrescu 
wrote:
> Sure. While you're young typecheck this:
>
> class A {
>    auto stuff() { ...; return this; }
> }
>
>
> Andrei

It would be a Borrowed!A, I would say, no matter how an A is 
allocated. A GC!A, an ARC!A and an Owning!A convert equally well 
to a Borrowed!A. As long as the Borrowed!A is in use (i.e. scope) 
after stuff() returns, the A object must not be freed (compiler 
enforced). Would that make sense?


More information about the Digitalmars-d mailing list