fixed GH# 188: Net: SocketAddress operator < unusable for std::map key

This commit is contained in:
Guenter Obiltschnig
2013-05-24 22:06:15 +02:00
parent 6ca49eb7f6
commit 28320ddb1e
2 changed files with 10 additions and 8 deletions

View File

@@ -161,9 +161,11 @@ SocketAddress::~SocketAddress()
bool SocketAddress::operator < (const SocketAddress& socketAddress) const bool SocketAddress::operator < (const SocketAddress& socketAddress) const
{ {
if (family() < socketAddress.family()) return true; if (family() < addr.family()) return true;
if (host() < socketAddress.host()) return true; if (family() > addr.family()) return false;
return (port() < socketAddress.port()); if (host() < addr.host()) return true;
if (host() > addr.host()) return false;
return (port() < addr.port());
} }

View File

@@ -147,7 +147,7 @@ void SocketAddressTest::testSocketRelationals()
SocketAddress sa3("192.168.1.101", "99"); SocketAddress sa3("192.168.1.101", "99");
assert (sa2 < sa3); assert (sa2 < sa3);
SocketAddress sa4("192.168.1.100", "102"); SocketAddress sa4("192.168.1.101", "102");
assert (sa3 < sa4); assert (sa3 < sa4);
} }