Issue 3789, stucts equality
Andrej Mitrovic
andrej.mitrovich at gmail.com
Thu Mar 29 05:07:03 PDT 2012
3/29/12, Andrej Mitrovic <andrej.mitrovich at gmail.com> wrote:
> snip
Crap, lockstep doesn't work on different types, it was iterating over
the arrays. That went over my head. A slightly complicated version
that actually works:
import std.stdio;
import std.conv;
string tupleCompare(int len)()
{
string result;
foreach (i; 0 .. len)
{
result ~= "
if (this.tupleof[" ~ to!string(i) ~ "] != t.tupleof[" ~
to!string(i) ~ "])
return false;
";
}
return result;
}
template safeOpEquals()
{
bool opEquals(typeof(this) t)
{
enum len = typeof(this).tupleof.length;
mixin(tupleCompare!len);
return true;
}
}
More information about the Digitalmars-d
mailing list