OpBinary

Wrap a binary operator overload.

  1. template OpBinary(string op, rhs_t = Guess)
    template OpBinary (
    string op
    rhs_t = Guess
    ) if (
    IsPyBinary(op) &&
    op != "in"
    ) {}
  2. template OpBinaryRight(string op, lhs_t = Guess)

Parameters

op

Operator to wrap

rhs_t

(optional) Type of opBinary's parameter for disambiguation if there are multiple overloads.

Bugs

Issue 8602 prevents disambiguation for case X opBinary(string op, T)(T t);

Examples

1 class Foo{
2     int _j;
3     int opBinary(string op)(int i) if(op == "+"){
4         return i+_j;
5     }
6     int opBinaryRight(string op)(int i) if(op == "+"){
7         return i+_j;
8     }
9 }
10 
11 class_wrap!(Foo,
12     OpBinary!("+"),
13     OpBinaryRight!("+"));

Meta