diff options
author | Steven Le Rouzic <steven.lerouzic@gmail.com> | 2024-11-14 23:23:29 +0100 |
---|---|---|
committer | Steven Le Rouzic <steven.lerouzic@gmail.com> | 2024-12-20 15:35:58 +0100 |
commit | ae9608d4f69a07c3efcf6ba9f38cb4ac23cc2110 (patch) | |
tree | 0d6bd8af8b3c334a12aaaf4bcfdd186942414220 /asl/string_view.hpp | |
parent | 75e956eac30050bb10d131b8f14ecbc396abcf17 (diff) |
Add string_view == operator
Diffstat (limited to 'asl/string_view.hpp')
-rw-r--r-- | asl/string_view.hpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/asl/string_view.hpp b/asl/string_view.hpp index 2e8efff..85f1323 100644 --- a/asl/string_view.hpp +++ b/asl/string_view.hpp @@ -70,6 +70,13 @@ public: ASL_ASSERT(offset >= 0 && offset <= m_size); return string_view{m_data + offset, m_size - offset}; // NOLINT(*-pointer-arithmetic) } + + constexpr bool operator==(string_view other) const + { + if (m_size != other.m_size) { return false; } + // @Todo Remove builtin_memcmp + return __builtin_memcmp(m_data, other.m_data, static_cast<size_t>(m_size)) == 0; + } }; } // namespace asl @@ -78,5 +85,3 @@ constexpr asl::string_view operator ""_sv(const char* s, size_t len) { return asl::string_view(s, static_cast<isize_t>(len)); } - -// @Todo Make comparison operator, replace in format and string_view tests |