Something weird happens when I try to foreach over test.tupleof.
If the foreach loop has 2 variables like so:
struct Test
{
string name = "'null'";
int id;
}
void main()
{
auto test = Test();
assert(test.name == "'null'");
assert(test.id == 0);
foreach (val1, val2; test.tupleof)
{
import std.stdio, std.conv, std.traits;
writeln(typeof(val1).stringof, "->", val1, " ",
typeof(val2).stringof, "->", val2);
}
}
The following is printed:
ulong->0 string->'null'
ulong->1 int->0
If the foreach only has 1 variable, like this:
foreach (val; test.tupleof)
{
import std.stdio, std.conv, std.traits;
writeln(typeof(val).stringof, "->", val);
}
The following is printed instead:
string->'null'
int->0
What is happening here? Are these two extra ulongs the offsets of
the fields in the struct?