Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9b919a9f authored by Pavlin Radoslavov's avatar Pavlin Radoslavov
Browse files

Inline comparison operators for RawAddress

Test: Code compilation
Bug: 64975965

Change-Id: I5a7ab7e0cd270c2769a3a471a506fc78a0a94533
parent 576be31d
Loading
Loading
Loading
Loading
+0 −8
Original line number Diff line number Diff line
@@ -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],
+6 −2
Original line number Diff line number Diff line
@@ -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; }