Meta-programming detecting anonymous unions inside structs.

rikki cattermole via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri Oct 21 01:18:58 PDT 2016


On 21/10/2016 9:13 PM, TheFlyingFiddle wrote:
> On Friday, 21 October 2016 at 07:56:27 UTC, rikki cattermole wrote:
>> You're gonna have to use UDA's for that.
>
> Yes, to do the serialization you're right.
>
> But my usecase for this is for error reporting. Basically any struct
> that contains unions without serialization instructions cannot be
> serialized and I want to make such structures errors.
>
> So when I try to serialize the example struct Foo. It should assert with
> something along the lines of:
>
> "Don't know how to serialize overlapping fields: "Foo.integer",
> "Foo.floating" and "Foo.array".

I suppose you could use .offsetof to determine this.



More information about the Digitalmars-d-learn mailing list