20.01.2017 15:04, Nestor пишет:
On Friday, 20 January 2017 at 08:13:08 UTC, drug wrote:
Something like that https://goo.gl/C4nOqw
Because you generate code iterating over AliasSeq you can do almost
everything you need - for example generate setters/getters.
Interesting site, I wouldn't implemente something like this in a public
server but sure it's useful.
Regarding the example, looks interesting though it raises s a few doubts
(forgive me if they sound silly):
What's UAP?
This code is part of an inhouse instrument, UAP is artifact of this
instrument, should be:
```
struct MyStruct(Fields...)
{
import std.bitmanip : bitfields;
mixin(makeBitfields!Fields); // <-- Fields instead of UAP
}
```
Where does one define the size for a field using AliasSeq, and in this
example, why does it take 1 bit if the size is not declared anywhere?
I have fields with size equal to one only, you can add another column to
AliasSeq to describe the size
(also, why does it compile when the last field terminates with a comma?)
it's feature of D for convenience
alias Fields = AliasSeq!(
ushort, "field0",
ubyte, "field1",
uint, "field2",
ubyte, "field3",
bool, "field4",
bool, "field5",
bool, "field6",
ubyte, "field7",
);
Why does the switch apply to the remainder of the modulo operation, does
Fields contains indexes to types and names as if it was an array?
May be does, I don't know so I use the remainder.