What does @nogc do to a class?

Mike Parker aldacron at gmail.com
Thu May 6 02:11:27 UTC 2021


On Thursday, 6 May 2021 at 01:04:02 UTC, Jack wrote:
> Does it allocate the object rather on stack, like auto scope a 
> = new A or what?

It doesn't do anything to classes. `@nogc` prevents you from any 
action triggers a GC allocation, such as using `new, so you would 
need to allocate from somewhere else (e.g., via `malloc`) for any 
class instances you want to create in a `@nogc` function.


More information about the Digitalmars-d-learn mailing list