Re: Best way to learn 2d games with D?
My two cents doing some 2D stuff for a while (a cards game). 1. stick to SDL2 if you want to have something that will work in many places. SFML AFAIK is not so compatible. From there, maybe I would start by mixing SDL2* libraries and using D with extern(C) interfaces if needed unless there is a well-maintained wrapper. The rest of the alternatives just brought trouble to me when trying to run in many systems.
Re: opDispatch with string mixin does not work as I would expect.
On Saturday, 10 February 2018 at 07:47:58 UTC, Nicholas Wilson wrote: On Saturday, 10 February 2018 at 06:32:43 UTC, German Diago Alternatively you could do something like auto opDispatch(string name)() if(hasMember!(HeaderData,name){ readHeader(); return mixin("headerData." ~ name); } Do not ask me why but now seems to work with my initial solution. :)
opDispatch with string mixin does not work as I would expect.
Hello everyone, I am trying to forward some member functions from a struct as a Catch-all function, so I did something like this: struct A { struct HeaderData { align(1): char [21] id; ubyte field1; ubyte field2; } Nullable!(HeaderData) headerData; auto opDispatch(string name)() { readHeader(); static foreach (member; __traits(allMembers, HeaderData)) { static if (name == member) { return mixin("headerData." ~ name); } } } The mixin line does not work. I want to generate the access to the field. How could I achieve that?