Using tupleof, named unions are not taken into account. Anonymous unions seem to work "just fine":
//----
import std.stdio;
import std.traits;
void main()
{
S s;
writeln(s.tupleof);
writeln(FieldTypeTuple!S.stringof);
}
//----
//----
struct S
{
union
{
int a;
int b;
}
}
//Produces:
00
(int, int)
//----
//----
struct S
{
union u
{
int a;
int b;
}
}
//Produces:
()
//----
This is quite bothersome, as it impacts FieldTypeTuple too.
Comment #1 by monarchdodra — 2014-01-30T00:30:49Z
Seems to also affect RepresentationTypeTuple
Comment #2 by k.hara.pg — 2014-01-30T01:12:50Z
(In reply to comment #0)
> struct S
> {
> union u
> {
> int a;
> int b;
> }
> }
It declares an union type inside struct S. a and b are in u, not in S. Therefore, struct S has no field, then s.tupleof.length == 0.
Comment #3 by monarchdodra — 2014-01-30T02:26:13Z
(In reply to comment #2)
> It declares an union type inside struct S. a and b are in u, not in S.
> Therefore, struct S has no field, then s.tupleof.length == 0.
Thanks :(