Hi everyone!

Given

struct Pair(T, U = T)
{
  T f;
  U s;
}

what is the intended way to genrically implement opCmp for this struct?

The naive approach

struct Pair(T, U = T)
{
  // [...]

  int opCmp(const Pair r) const
  {
    immutable c = f.opCmp(r.f);
    return c != 0 ? c : s.opCmp(r.s);
  }
}

yields

Error: no property 'opCmp' for type 'const(int)'

if one tries to compare pairs of int.

Reply via email to