trait detecting anonymous union?

Bastiaan Veelo via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon May 22 14:03:42 PDT 2017


`
void main()
{
	import std.stdio;
	struct S
	{
		int i;
		union
		{
			int a;
                         double b;
		}
	}
	S s;
	writeln(s);                  // S(10, #{overlap a, b})
	import std.traits;
	writeln([FieldNameTuple!S]); // ["i", "a", "b"]
}
`

Is there a way to detect at CT that S has overlapping data 
members, when an anonimous union is used as above?

Thanks,
Bastiaan.


More information about the Digitalmars-d-learn mailing list