move object from heap to stack

monarch_dodra monarchdodra at gmail.com
Thu Sep 20 07:03:01 PDT 2012


On Thursday, 20 September 2012 at 12:32:03 UTC, Namespace wrote:
> So I should disable the copy ctor (@disable this(this)) and 
> drop move, right?
Yes, but at that point, what you have is scoped!T re-implemented 
:/

> As you can See if I pass a OnStack to function/class i'm using 
> .get all the Time.
You could "alias get this". This way, your OnStack will call cast 
as a T implicitly. Again, this is what scoped!T does.

> The only other method IMO would be to pass it as OnStack by 
> value and Store it in the other class also as OnStack, right?

Yes, but that would require a copy contructor "this(this)", which 
we have actually ruled out. You can pass the T itself thanks to 
the implicit cast to T, but you can't pass an actual OnStack 
object.


More information about the Digitalmars-d-learn mailing list