Implement proper equal operators

This commit is contained in:
Chocobo1
2019-08-08 23:19:53 +08:00
parent d639c16f72
commit 94f7a095bb
3 changed files with 20 additions and 19 deletions

View File

@@ -50,18 +50,18 @@ public:
TriStateBool &operator=(const TriStateBool &other) = default; // add constexpr when using C++17
constexpr bool operator==(const TriStateBool &other) const
constexpr friend bool operator==(const TriStateBool &left, const TriStateBool &right)
{
return (m_value == other.m_value);
}
constexpr bool operator!=(const TriStateBool &other) const
{
return !operator==(other);
return (left.m_value == right.m_value);
}
private:
signed char m_value = -1; // Undefined by default
};
constexpr bool operator!=(const TriStateBool &left, const TriStateBool &right)
{
return !(left == right);
}
#endif // TRISTATEBOOL_H