diff options
| author | Felix Morgner <felix.morgner@ost.ch> | 2026-03-19 15:08:18 +0100 |
|---|---|---|
| committer | Felix Morgner <felix.morgner@ost.ch> | 2026-03-19 15:08:18 +0100 |
| commit | c2ba7be0e1e84752d21abdcb4ec4f9df444bc367 (patch) | |
| tree | e8a78a4bb68927bd0259acd6dd72d753847ca9b9 /libs | |
| parent | cabcb0a8365e4d9dc8245b618f00d105e757e8d9 (diff) | |
| download | teachos-c2ba7be0e1e84752d21abdcb4ec4f9df444bc367.tar.xz teachos-c2ba7be0e1e84752d21abdcb4ec4f9df444bc367.zip | |
kstd: add vector comparison operators
Diffstat (limited to 'libs')
| -rw-r--r-- | libs/kstd/include/kstd/vector | 15 |
1 files changed, 15 insertions, 0 deletions
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<typename ValueType, typename Allocator> + constexpr auto operator==(vector<ValueType, Allocator> const & lhs, vector<ValueType, Allocator> const & rhs) -> bool + { + return std::ranges::equal(lhs, rhs); + } + + //! Perform a lexicographical comparison of the content of two vectors. + template<typename ValueType, typename Allocator> + constexpr auto operator<=>(vector<ValueType, Allocator> const & lhs, vector<ValueType, Allocator> const & rhs) + -> decltype(std::declval<ValueType const &>() <=> std::declval<ValueType const &>()) + { + return std::lexicographical_compare_three_way(lhs.begin(), lhs.end(), rhs.begin(), rhs.end()); + } + } // namespace kstd #endif |
