Specifying @nogc on structs seems to have no effect

Andrea Fontana nospam at example.com
Tue Sep 19 13:31:40 UTC 2017


On Tuesday, 19 September 2017 at 13:13:48 UTC, Craig Black wrote:
> @nogc struct Array(T)
> {
>   ...
> }
>
> class GarbageCollectedClass
> {
> }
>
> void main()
> {
>   Array!int intArray; // fine
>   Array!GarbageCollectedClass classArray; // Error: struct 
> Array is @nogc
>
> }

If you want to enforce that behaviour I guess you can use 
reflection to check if T has attribute @nogc.

Andrea


More information about the Digitalmars-d mailing list