add reverse operators

This commit is contained in:
J. Nick Koston
2026-02-11 12:20:36 -06:00
parent ce5b93d9ca
commit fc7e9c8a0c

View File

@@ -1841,4 +1841,10 @@ class CompactString {
static_assert(sizeof(CompactString) == 20, "CompactString must be exactly 20 bytes");
// Reverse comparison overloads so CompactString works on either side of == and !=
inline bool operator==(const std::string &lhs, const CompactString &rhs) { return rhs == lhs; }
inline bool operator==(const char *lhs, const CompactString &rhs) { return rhs == lhs; }
inline bool operator!=(const std::string &lhs, const CompactString &rhs) { return !(rhs == lhs); }
inline bool operator!=(const char *lhs, const CompactString &rhs) { return !(rhs == lhs); }
} // namespace esphome