On Tuesday, 19 September 2017 at 13:46:20 UTC, Craig Black wrote:

Thanks, I didn't know you could to that but it still doesn't give me the behavior that I want:

class Foo
{
}

struct MyStruct
{
@nogc:
public:
Foo foo; // This does not produce an error, but it still requires a GC scan
  void Bar()
  {
    foo = new Foo; // This produces an error
  }
}

@nogc applies to functions, not to types or variables. It prevents actions that allocate, like calls to new, appending to or concatenating arrays, and so on, inside the annotated function. By extension, no sort of GC scanning or collections will occur in such functions because that sort of thing can only happen during an allocation.

Reply via email to