opCmp with template type not working.
Jonathan Levi
catanscout at gmail.com
Tue Nov 3 02:55:46 UTC 2020
This is not working as expected:
> bool opCmp(string op, U)(U rhs) {
As it does work with:
> auto opBinary(string op, U)(U rhs) {
With:
> struct X {
> int x;
> auto opBinary(string op, U)(U rhs) {
> return mixin("x "~op~" rhs");
> }
> bool opCmp(string op, U)(U rhs) {
> return mixin("x "~op~" rhs");
> }
> }
This compiles:
> X(5) + 4
This does not:
> X(5) < 4
Full example code: https://run.dlang.io/is/Beflkt
Is this a Bug?
More information about the Digitalmars-d
mailing list