The OpenD Programming Language

isTwoWayCompatible

Returns true if fn accepts variables of type T1 and T2 in any order. The following code should compile:

(ref T1 a, ref T2 b)
{
  fn(a, b);
  fn(b, a);
}
template isTwoWayCompatible (
alias fn
T1
T2
) {
enum isTwoWayCompatible;
}

Examples

void func1(int a, int b);
void func2(int a, float b);

static assert(isTwoWayCompatible!(func1, int, int));
static assert(isTwoWayCompatible!(func1, short, int));
static assert(!isTwoWayCompatible!(func2, int, float));

void func3(ref int a, ref int b);
static assert( isTwoWayCompatible!(func3, int, int));
static assert(!isTwoWayCompatible!(func3, short, int));

Meta