How to do operator overloading for <, >, <=, >=, !=, and == between struct and int?

Ferhat Kurtulmuş aferust at gmail.com
Sun Apr 21 18:07:08 UTC 2019


I am writing an opencv binding and need something like: Mat m = 
another_mat > 5;
Docs does not cover this sitiuation: 
https://dlang.org/spec/operatoroverloading.html#compare
opBinary does not support those operators, and Section 
"Overloading <, <=, >, and >=" describes overloaded operators 
returning only int values.

My struct is defined here: 
https://github.com/aferust/opencvd/blob/master/source/opencvd/cvcore.d


More information about the Digitalmars-d-learn mailing list