From c2ba7be0e1e84752d21abdcb4ec4f9df444bc367 Mon Sep 17 00:00:00 2001 From: Felix Morgner Date: Thu, 19 Mar 2026 15:08:18 +0100 Subject: kstd: add vector comparison operators --- libs/kstd/include/kstd/vector | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'libs/kstd/include') diff --git a/libs/kstd/include/kstd/vector b/libs/kstd/include/kstd/vector index de5c059..f8e9ce2 100644 --- a/libs/kstd/include/kstd/vector +++ b/libs/kstd/include/kstd/vector @@ -728,6 +728,21 @@ namespace kstd value_type * m_data{}; }; + //! Check if the content of two vectors is equal. + template + constexpr auto operator==(vector const & lhs, vector const & rhs) -> bool + { + return std::ranges::equal(lhs, rhs); + } + + //! Perform a lexicographical comparison of the content of two vectors. + template + constexpr auto operator<=>(vector const & lhs, vector const & rhs) + -> decltype(std::declval() <=> std::declval()) + { + return std::lexicographical_compare_three_way(lhs.begin(), lhs.end(), rhs.begin(), rhs.end()); + } + } // namespace kstd #endif -- cgit v1.2.3