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

Commit 6f15687d authored by Jakub Tyszkowski's avatar Jakub Tyszkowski
Browse files

uuid: Fix visibility issue for stream operator

This fixes compiler not finding the proper stream operator in some
cases. It seems to be dependent on the order in which stream operators
for different classes are being defined in the compilation unit. Even
defining such operator for one class at the top of the file could break
compilation down bellow in the Uuid printing code that already worked
for a long time, just as if the needed symbol got somehow erased.

An example of such error for the Uuuid instance printed in groups.cc:
  groups.cc:372:21: error: invalid operands to binary expression ('basic_ostream<char, std::char_traits<char>>' and 'const bluetooth::Uuid')
    << ", Uuid: " << group.group_uuid_
    ~~~~~~~~~~~~~ ^  ~~~~~~~~~~~~~~~~~

Moving the operator<<(...) to its 1st argument class namespace fixes
that.

Bug: 150670922
Tag: #feature
Test: atest --host net_test_types
Sponsor: jpawlowski@
Change-Id: I73bb3476f480bbffeb140dcd33eb6b521506446b
parent 4cd9f204
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -119,13 +119,14 @@ class Uuid final {
  // Network-byte-ordered ID (Big Endian).
  UUID128Bit uu;
};
}  // namespace bluetooth

inline std::ostream& operator<<(std::ostream& os, const bluetooth::Uuid& a) {
  os << a.ToString();
  return os;
}

}  // namespace bluetooth

// Custom std::hash specialization so that bluetooth::UUID can be used as a key
// in std::unordered_map.
namespace std {