From: Pavlin Radoslavov Date: Wed, 30 Aug 2017 18:02:27 +0000 (-0700) Subject: Inline comparison operators for RawAddress X-Git-Tag: android-x86-9.0-r1~186^2~4^2~2^2~132^2 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=c705670fbec2d404a92261efa0234c614232ec4f;p=android-x86%2Fsystem-bt.git Inline comparison operators for RawAddress Test: Code compilation Bug: 64975965 Change-Id: I5a7ab7e0cd270c2769a3a471a506fc78a0a94533 --- diff --git a/types/raw_address.cc b/types/raw_address.cc index 83fce6eb7..22c1081ef 100644 --- a/types/raw_address.cc +++ b/types/raw_address.cc @@ -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], diff --git a/types/raw_address.h b/types/raw_address.h index b7e4e0fd1..0b42c0453 100644 --- a/types/raw_address.h +++ b/types/raw_address.h @@ -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; }