InternetAddress comparison fail

Jon via Digitalmars-d digitalmars-d at puremagic.com
Fri Jan 2 21:32:38 PST 2015


On Saturday, 3 January 2015 at 03:11:05 UTC, David Eagen wrote:
> On Saturday, 3 January 2015 at 01:16:39 UTC, Jonathan Marler 
> wrote:
>> Why doesn't the equals operator work on the InternetAddress 
>> class?
>>
>> import std.stdio;
>> import std.socket;
>> void main()
>> {
>>  auto addr1 = new InternetAddress("192.168.0.1", 80);
>>  auto addr2 = new InternetAddress("192.168.0.1", 80);
>>  assert(addr1 == addr2); // FAILS
>> }
>>
>> If I am not mistaken, the == operator is overriden by the 
>> opEquals method.  I don't see any opEquals method in 
>> std.socket so I'm wondering if this is by design or someone 
>> overlooked it?
>
> I ran into this too and made a helper to do the comparison 
> (using toAddrString) so I could move forward with my project.
>
> Adding opEquals and opCmp is probably low-hanging fruit and a 
> good place for someone to start working on Phobos.

Still, shouldn't the == operator do a deep compare of the two 
InternetAddress objects in the absence of a defined opEquals 
method? I don't see why it should fail in the above example.

-Jon


More information about the Digitalmars-d mailing list