diff --git a/include/rfl/Literal.hpp b/include/rfl/Literal.hpp index bc99fa1f..87ce4859 100644 --- a/include/rfl/Literal.hpp +++ b/include/rfl/Literal.hpp @@ -161,9 +161,32 @@ class Literal { return *this; } - /// Equality operator other Literals. - bool operator==(const Literal& _other) const { - return value() == _other.value(); + /// <=> for other Literals with the same fields. + auto operator<=>(const Literal& _other) const { + return value() <=> _other.value(); + } + + /// <=> for other Literals with different fields. + template + inline auto operator<=>(const Literal<_fields...>& _l2) const { + return name() <=> _l2.name(); + } + + /// <=> for strings. + inline auto operator<=>(const std::string& _str) const { + return name() <=> _str; + } + + /// <=> for const char*. + template + inline auto operator<=>(const char* _str) const { + return name() <=> _str; + } + + /// Equality operator. + template + bool operator==(const Other& _other) const { + return (*this <=> _other) == 0; } /// Alias for .name(). @@ -335,28 +358,6 @@ inline constexpr auto value_of() { return LiteralType::template value_of<_name>(); } -/// <=> for other Literals with the same fields. -template -inline auto operator<=>(const Literal& _l1, - const Literal& _l2) { - return _l1.value() <=> _l2.value(); -} - -/// <=> for other Literals with different fields. -template -inline auto operator<=>(const Literal& _l1, - const Literal& _l2) { - return _l1.name() <=> _l2.name(); -} - -/// <=> for strings. -template -inline auto operator<=>(const Literal& _l, - const std::string& _str) { - return _l <=> _str; -} - } // namespace rfl namespace std {