diff options
| author | marcel.braun <marcel.braun@ost.ch> | 2026-03-23 21:40:34 +0100 |
|---|---|---|
| committer | Lukas Oesch <lukasoesch20@gmail.com> | 2026-03-26 21:18:53 +0100 |
| commit | 336b25458b75e28c93c0bab23ccd359042f9df41 (patch) | |
| tree | 00d0c0c51314a8f8018b76aded1a48be76a88338 /libs/kstd | |
| parent | 7173e5ba354dccc4b5d5fea119b946f28bc5b08f (diff) | |
| download | teachos-336b25458b75e28c93c0bab23ccd359042f9df41.tar.xz teachos-336b25458b75e28c93c0bab23ccd359042f9df41.zip | |
Implement == and != operators for string and string_view
Diffstat (limited to 'libs/kstd')
| -rw-r--r-- | libs/kstd/include/kstd/string | 31 |
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 |
