Create an Algebraic type at compile time and more
uknys
uknysx at pm.me
Thu Jun 14 19:15:38 UTC 2018
Hello,
I wanted to know if such code was possible :
alias Operation = Algebraic!(/* All type that implements X UDA */)
struct X
{
int opcode;
Operation h;
}
@X(0x01, Hello(3))
@X(0x02, Hello(4))
struct Hello
{
int Hello;
}
@X(0x03, Toto(5))
@X(0x05, Toto(6))
struct Toto
{
int A;
}
It has two problems, Operation not being defined while I use it
in the UDA, and how to get back all the types that implements
this UDA to give it to Algebraic.
I don't know if it's a good idea or not, but might as well try
the dark side of meta programming.
Thanks a lot :)
More information about the Digitalmars-d-learn
mailing list