iterating through members of bitfields
Nestor via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Tue Jan 17 16:37:26 PST 2017
Hi,
I was just looking at an interesting function from
http://codepad.org/lSDTFd7E :
void printFields(T)(T args) {
auto values = args.tupleof;
size_t max;
size_t temp;
foreach (index, value; values) {
temp = T.tupleof[index].stringof.length;
if (max < temp) max = temp;
}
max += 1;
foreach (index, value; values) {
writefln("%-" ~ to!string(max) ~ "s %s",
T.tupleof[index].stringof, value);
}
}
Can something similar be done for bitfields? I tried running this
and I only get something like this:
_f01_f02_f03 25312
_f04_f05_f06_f07 21129
_f08_f09_f10 53575
_f11_f12_f13_f14 9264
More information about the Digitalmars-d-learn
mailing list