UDA and trait for non-GC managed pointers

Nordlöw via Digitalmars-d digitalmars-d at puremagic.com
Sat Oct 15 09:22:35 PDT 2016


Is there a way to check if a pointer is supposed to point to 
non-GC allocated memory? I presume not. This is needed to prevent 
unnecessary calls to `GC.addRange` in containers with elements of 
a type that in turn is a container-like struct with non-GC 
allocated memory.

If not, maybe we could tag those non-GC-mangaged pointers with a 
UDA, preferrably `@nogc`, and then build a trait, say, 
`hasGCIndirections` that doesn't include @nogc-pointers.

What do you think?


More information about the Digitalmars-d mailing list