MustAddGcRange

Indicates if an aggregate contains members that might be collected by the garbage collector. This is used in construct to determine if the content of a manually allocated aggregate must be declared to the GC.

template MustAddGcRange (
T
) if (
is(T == struct) ||
is(T == union)
||
is(T == class)
) {
auto MustAddGcRange;
auto MustAddGcRange;
}

Examples

1 // 'a' will be managed with expand/Shrink
2 class Foo{@NoGc int[] a; @NoGc void* b;}
3 static assert(!MustAddGcRange!Foo);
4 // 'a' will be managed with '.length' so druntime.
5 class Bar{int[] a; @NoGc void* b;}
6 // b's annotation is canceled by a type.
7 static assert(MustAddGcRange!Bar);
8 // Baz base is not @NoGc
9 class Baz: Bar{@NoGc void* c;}
10 static assert(MustAddGcRange!Baz);

Meta