[Issue 5281] Equality among arrays of Bigints

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Nov 28 08:28:42 PST 2010


http://d.puremagic.com/issues/show_bug.cgi?id=5281


Matthias Walter <xammy at xammy.homelinux.net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |xammy at xammy.homelinux.net
         OS/Version|Windows                     |All


--- Comment #1 from Matthias Walter <xammy at xammy.homelinux.net> 2010-11-28 08:27:14 PST ---
More precisely, the issue is that in the following code, the opEquals method is
not called for the array comparison. As it seems, the only opEquals signature
working for array comparison is "bool opEquals (ref const BigInt y) const",
making it impossible to have more versions to compare to different types.

struct BigInt
{
    bool opEquals (Tdummy = void)(ref const BigInt y) const
    {
      writefln("BigInt.opEquals!void(BigInt) called");
      return true;
    }

    bool opEquals (T: long) (long y) const
    {
      writefln("BigInt.opEquals!long called");
      return true;
    }
}

void main()
{
  BigInt i,j;

  writefln("i == j: %s", i == j);
  writefln("[i] == [j]: %s", [i] == [j]);
}

The output is:

BigInt.opEquals!void(BigInt) called
i == j: true
[i] == [j]: true

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list