Create an Algebraic type at compile time and more

2018-06-14 Thread uknys via Digitalmars-d-learn
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

Re: Create an Algebraic type at compile time and more

2018-06-15 Thread uknys via Digitalmars-d-learn
On Friday, 15 June 2018 at 07:27:22 UTC, Simen Kjærås wrote: On Thursday, 14 June 2018 at 19:15:38 UTC, uknys wrote: [...] First off - Algebraic doesn't work at compile-time[0]: // Error: memcpy cannot be interpreted at compile time, because it has no available source code enum a = Algebrai

Re: Create an Algebraic type at compile time and more

2018-06-16 Thread uknys via Digitalmars-d-learn
On Friday, 15 June 2018 at 12:03:28 UTC, Simen Kjærås wrote: On Friday, 15 June 2018 at 10:53:35 UTC, uknys wrote: On Friday, 15 June 2018 at 07:27:22 UTC, Simen Kjærås wrote: [snip] Yeah I saw that Algebraic doesn't work at compile time, then I thought of using an Interface with one functio