Create class on stack

angel via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat Aug 5 13:27:29 PDT 2017


On Saturday, 5 August 2017 at 17:08:32 UTC, Johnson Jones wrote:
> using gtk, it has a type called value. One has to use it to get 
> the value of stuff but it is a class. Once it is used, one 
> doesn't need it.
>
> Ideally I'd like to treat it as a struct since I'm using it in 
> a delegate I would like to minimize unnecessary allocations. Is 
> there any way to get D to allocate a class on the stack like a 
> local struct?

Emplace ?
https://dlang.org/phobos/std_conv.html#emplace



More information about the Digitalmars-d-learn mailing list