On Thursday, 19 December 2024 at 18:49:28 UTC, sfp wrote:
Subject lines says it all, I think... The choice to make binary operators implementable only via this `opBinary` template means it's unclear how to get virtual operators on an interface.


I am very new to D, and my goal is to learn how to solve this problem using classic, runtime, dynamic polymorphism in D (so, please don't suggest that I solve a different problem, suggest that I use a particular library, a different technique, etc.). Thanks in advance.

As said virtual functions cannot be templates. However you can use alias to essentially define what you want your operators to be called.

I wrote a blog post on how to use a single mixin to forward all operators to the D1 style overloads. You might find it useful or inspiring.

https://www.schveiguy.com/blog/2022/06/how-to-keep-using-d1-operator-overloads/

-Steve

Reply via email to