Extra .tupleof field in structs with disabled postblit blocks non-GC-allocation trait
Per Nordlöw
per.nordlow at gmail.com
Wed May 9 14:20:41 UTC 2018
On Wednesday, 9 May 2018 at 14:07:37 UTC, Per Nordlöw wrote:
> This prevents the trait `mustAddGCRangeOfStructOrUnion` [1]
> from detecting when a container with manual memory management
> doesn't have to be scanned by the GC as in, for instance,
>
> enum NoGc;
> struct S
> {
> @disable this(this); // disable S postlib
> @NoGc int* _ptr;
> }
> static assert(!mustAddGCRangeOfStructOrUnion!S); // is
> false when postblit of `S` is disabled
>
> [1]
> https://github.com/nordlow/phobos-next/blob/master/src/gc_traits.d#L81
Can we statically check if the postblit has been disabled via
@disable this(this);
?
If so, we can temporarily modify the trait to exclude the last
`void*` member of the `S.tuple`. Given that it's always added as
the last member.
More information about the Digitalmars-d-learn
mailing list