Re: templates and traits

2023-03-18 Thread Chris Katko via Digitalmars-d-learn
On Saturday, 18 March 2023 at 20:42:50 UTC, Nick Treleaven wrote: On Saturday, 18 March 2023 at 19:22:07 UTC, Chris Katko wrote: ... So there's multiple sub-problems to solve. I asked this years ago, and got 90% of the way done and then lost the code and cannot find the original forum post.

Re: templates and traits

2023-03-18 Thread Nick Treleaven via Digitalmars-d-learn
On Saturday, 18 March 2023 at 19:22:07 UTC, Chris Katko wrote: ... So there's multiple sub-problems to solve. I asked this years ago, and got 90% of the way done and then lost the code and cannot find the original forum post. Maybe it was this?:

templates and traits

2023-03-18 Thread Chris Katko via Digitalmars-d-learn
Given: ```D struct pos {float x, y;} draw(myBitmap, pos(320, 240), centered); draw(pos(320, 240), myBitmap); draw("text", myFont, pos(320, 240)); ``` I'm writing a general "draw" template function that through compile-time, calls an associated DAllegro/Allegro 5 function: ``` draw(myBitmap,