From 336b25458b75e28c93c0bab23ccd359042f9df41 Mon Sep 17 00:00:00 2001 From: "marcel.braun" Date: Mon, 23 Mar 2026 21:40:34 +0100 Subject: Implement == and != operators for string and string_view --- libs/kstd/include/kstd/string | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'libs') diff --git a/libs/kstd/include/kstd/string b/libs/kstd/include/kstd/string index f9583d5..075422e 100644 --- a/libs/kstd/include/kstd/string +++ b/libs/kstd/include/kstd/string @@ -312,6 +312,37 @@ namespace kstd std::reverse(result.begin(), result.end()); return result; } + + [[nodiscard]] constexpr auto inline operator==(string const & lhs, string const & rhs) -> bool + { + return lhs.view() == rhs.view(); + } + + [[nodiscard]] constexpr auto inline operator!=(string const & lhs, string const & rhs) -> bool + { + return !(lhs == rhs); + } + + [[nodiscard]] constexpr auto inline operator==(string const & lhs, std::string_view rhs) -> bool + { + return lhs.view() == rhs; + } + + [[nodiscard]] constexpr auto inline operator!=(string const & lhs, std::string_view rhs) -> bool + { + return !(lhs == rhs); + } + + [[nodiscard]] constexpr auto inline operator==(std::string_view lhs, string const & rhs) -> bool + { + return lhs == rhs.view(); + } + + [[nodiscard]] constexpr auto inline operator!=(std::string_view lhs, string const & rhs) -> bool + { + return !(lhs == rhs); + } + } // namespace kstd #endif \ No newline at end of file -- cgit v1.2.3