Get operator overloads
    Ivan Timokhin via Digitalmars-d-learn 
    digitalmars-d-learn at puremagic.com
       
    Tue Sep  2 11:55:34 PDT 2014
    
    
  
Is it possible to get all overloads of an operator for a particular type?
I.e., having this struct definition, is it possible to tell at compile 
time that it can be added with double and int[]?
struct S
{
     void opBinary(string op : "+")(double);
     void opBinary(string op : "+")(int[]);
}
To clarify, I am well aware that it can also be overloaded through the 
second argument via opBinaryRight, but for now I'm only interested in 
overloads provided by S itself.
I've tried __traits(getOverloads), but with no success: 
__traits(getOverloads, S, "opBinary") returns empty tuple,
and __traits(getOverloads, S, `opBinary!"+"`) results in a compilation
error (dmd 2.065):
Error: no property 'opBinary!"+"' for type 'S'
Error: (S).opBinary!"+" cannot be resolved
    
    
More information about the Digitalmars-d-learn
mailing list