aboutsummaryrefslogtreecommitdiff
path: root/libs
diff options
context:
space:
mode:
authormarcel.braun <marcel.braun@ost.ch>2026-03-23 21:40:34 +0100
committerLukas Oesch <lukasoesch20@gmail.com>2026-03-26 21:18:53 +0100
commit336b25458b75e28c93c0bab23ccd359042f9df41 (patch)
tree00d0c0c51314a8f8018b76aded1a48be76a88338 /libs
parent7173e5ba354dccc4b5d5fea119b946f28bc5b08f (diff)
downloadteachos-336b25458b75e28c93c0bab23ccd359042f9df41.tar.xz
teachos-336b25458b75e28c93c0bab23ccd359042f9df41.zip
Implement == and != operators for string and string_view
Diffstat (limited to 'libs')
-rw-r--r--libs/kstd/include/kstd/string31
1 files changed, 31 insertions, 0 deletions
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