+ if (external_) {
+ // Anonymous addresses can't be compared to anything else.
+ // Return that they are never less than anything.
+ //
+ // Note that this still meets the requirements for a strict weak
+ // ordering, so we can use this operator<() with standard C++ containers.
+ size_t thisPathLength = storage_.un.pathLength();
+ if (thisPathLength == 0) {
+ return false;
+ }
+ size_t otherPathLength = other.storage_.un.pathLength();
+ if (otherPathLength == 0) {
+ return true;
+ }
+
+ // Compare based on path length first, for efficiency
+ if (thisPathLength != otherPathLength) {
+ return thisPathLength < otherPathLength;
+ }
+ int cmp = memcmp(storage_.un.addr->sun_path,
+ other.storage_.un.addr->sun_path,
+ thisPathLength);
+ return cmp < 0;
+ }