Classes on stack
Redwan
rdwnsjjd at gmail.com
Thu Sep 1 09:43:55 UTC 2022
On Thursday, 1 September 2022 at 09:40:06 UTC, Dennis wrote:
> On Thursday, 1 September 2022 at 09:13:56 UTC, Redwan wrote:
>> I want declare classes and create instance of them on stack
>> and nicely use them.
>
> You can use that using the `scope` storage class on a local
> variable with a class type:
>
> https://dlang.org/spec/attribute.html#scope-class-var
>
> ```D
> void main() @nogc
> {
> scope o = new Object();
> }
> ```
>
> The `@nogc` attribute ensures no allocations are made with the
> Garbage Collector.
oh, thank you. with this, no allocation??
More information about the Digitalmars-d
mailing list