aboutsummaryrefslogtreecommitdiff
path: root/src/string.cpp
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2024-04-15 12:43:45 +0100
committergingerBill <bill@gingerbill.org>2024-04-15 12:43:45 +0100
commit36644a3c09630cc75e7826ec443bb760bdbbd4af (patch)
treeb2e71fac5df6a00890d00dde757f9b2080785334 /src/string.cpp
parent7e582dd671addfd2119b0a9016635cdaddc6b22f (diff)
Add template specialization for compared against `""` with `String` internally
Diffstat (limited to 'src/string.cpp')
-rw-r--r--src/string.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/string.cpp b/src/string.cpp
index 7bfa52f33..4adec7a90 100644
--- a/src/string.cpp
+++ b/src/string.cpp
@@ -171,6 +171,9 @@ template <isize N> gb_internal bool operator > (String const &a, char const (&b
template <isize N> gb_internal bool operator <= (String const &a, char const (&b)[N]) { return str_le(a, make_string(cast(u8 *)b, N-1)); }
template <isize N> gb_internal bool operator >= (String const &a, char const (&b)[N]) { return str_ge(a, make_string(cast(u8 *)b, N-1)); }
+template <> bool operator == (String const &a, char const (&b)[1]) { return a.len == 0; }
+template <> bool operator != (String const &a, char const (&b)[1]) { return a.len != 0; }
+
gb_internal gb_inline bool string_starts_with(String const &s, String const &prefix) {
if (prefix.len > s.len) {
return false;