diff options
Diffstat (limited to 'nihil.ucl/object.ccm')
| -rw-r--r-- | nihil.ucl/object.ccm | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/nihil.ucl/object.ccm b/nihil.ucl/object.ccm index 0b8c95f..43f36fe 100644 --- a/nihil.ucl/object.ccm +++ b/nihil.ucl/object.ccm @@ -170,6 +170,29 @@ private: }; /*********************************************************************** + * Object comparison. + */ + +export auto operator<=>(object const &lhs, object const &rhs) + -> std::strong_ordering +{ + auto cmp = ::ucl_object_compare(lhs.get_ucl_object(), + rhs.get_ucl_object()); + + if (cmp < 0) + return std::strong_ordering::less; + else if (cmp > 0) + return std::strong_ordering::greater; + else + return std::strong_ordering::equal; +} + +export auto operator==(object const &lhs, object const &rhs) -> bool +{ + return (lhs <=> rhs) == std::strong_ordering::equal; +} + +/*********************************************************************** * Object iteration. */ |
