OSDN Git Service

Inline comparison operators for RawAddress
authorPavlin Radoslavov <pavlin@google.com>
Wed, 30 Aug 2017 18:02:27 +0000 (11:02 -0700)
committerPavlin Radoslavov <pavlin@google.com>
Wed, 30 Aug 2017 18:02:27 +0000 (11:02 -0700)
Test: Code compilation
Bug: 64975965

Change-Id: I5a7ab7e0cd270c2769a3a471a506fc78a0a94533

types/raw_address.cc
types/raw_address.h

index 83fce6e..22c1081 100644 (file)
@@ -33,14 +33,6 @@ RawAddress::RawAddress(const uint8_t (&addr)[6]) {
   std::copy(addr, addr + kLength, address);
 };
 
-bool RawAddress::operator<(const RawAddress& rhs) const {
-  return std::memcmp(address, rhs.address, sizeof(address)) < 0;
-}
-
-bool RawAddress::operator==(const RawAddress& rhs) const {
-  return std::memcmp(address, rhs.address, sizeof(address)) == 0;
-}
-
 std::string RawAddress::ToString() const {
   return base::StringPrintf("%02x:%02x:%02x:%02x:%02x:%02x", address[0],
                             address[1], address[2], address[3], address[4],
index b7e4e0f..0b42c04 100644 (file)
@@ -30,11 +30,15 @@ class RawAddress final {
   RawAddress() = default;
   RawAddress(const uint8_t (&addr)[6]);
 
-  bool operator<(const RawAddress& rhs) const;
+  bool operator<(const RawAddress& rhs) const {
+    return (std::memcmp(address, rhs.address, sizeof(address)) < 0);
+  }
+  bool operator==(const RawAddress& rhs) const {
+    return (std::memcmp(address, rhs.address, sizeof(address)) == 0);
+  }
   bool operator>(const RawAddress& rhs) const { return (rhs < *this); }
   bool operator<=(const RawAddress& rhs) const { return !(*this > rhs); }
   bool operator>=(const RawAddress& rhs) const { return !(*this < rhs); }
-  bool operator==(const RawAddress& rhs) const;
   bool operator!=(const RawAddress& rhs) const { return !(*this == rhs); }
 
   bool IsEmpty() const { return *this == kEmpty; }