mirror of
https://github.com/esphome/esphome.git
synced 2026-03-01 02:14:19 -07:00
add reverse operators
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user