On Tuesday, 19 March 2013 at 08:25:45 UTC, timotheecour wrote:
we need a std.algorithm.equalRecurse(T1,T2)(T1 a, T2 b) that compares recursively a and b;

its behavior should be:

if opEqual is defined, call it
else, if its a range, call std.algorithm.equal (ie compare nb elements, then each element for equality) else, if it's a class/struct, make sure types are same and call it recursively on each field.
else if it's a numerical type, call "=="
else (is there an else?)

Not recursively, but how about something like this?
1) One type, one other
   -> false
2) Both types
   -> is(A == B)
3) Both symbols && __traits(isSame)
   -> true
4) A symbol && __traits(compiles, (A.opEquals(B)))
   -> A.opEquals(B)
5) B symbol && __traits(compiles, (B.opEquals(A)))
   -> B.opEquals(A)
6) A symbol && __traits(compiles, (A.equals(B)))
   -> A.equals(B)
7) B symbol && __traits(compiles, (B.equals(A)))
   -> B.equals(A)
8) Both symbols or values && __traits(compiles, A == B)
   -> A == B
9) assert(0)

Reply via email to