aboutsummaryrefslogtreecommitdiff
path: root/zencore/include
diff options
context:
space:
mode:
authorDan Engelbrecht <[email protected]>2022-05-12 10:40:31 +0200
committerDan Engelbrecht <[email protected]>2022-05-12 10:41:37 +0200
commit992f21133f83f6e0a2a99136906cb2e07d6c0842 (patch)
treec6097bea3e0a6da924c63f06418b1e83779a0c25 /zencore/include
parentmanual <=> calls for strings in CacheKey (diff)
downloadzen-992f21133f83f6e0a2a99136906cb2e07d6c0842.tar.xz
zen-992f21133f83f6e0a2a99136906cb2e07d6c0842.zip
Add caseSensitiveCompareStrings and manual <=> and == operator for CacheKey
MacOS clang compiler does not implement a default <=> operator for string
Diffstat (limited to 'zencore/include')
-rw-r--r--zencore/include/zencore/string.h23
1 files changed, 23 insertions, 0 deletions
diff --git a/zencore/include/zencore/string.h b/zencore/include/zencore/string.h
index 012ee73ee..fe838ac19 100644
--- a/zencore/include/zencore/string.h
+++ b/zencore/include/zencore/string.h
@@ -9,6 +9,7 @@
#include <string.h>
#include <charconv>
#include <codecvt>
+#include <compare>
#include <concepts>
#include <optional>
#include <span>
@@ -795,6 +796,28 @@ StrCaseCompare(const char* Lhs, const char* Rhs, int64_t Length = -1)
#endif
}
+/**
+ * @brief
+ * Helper function to implement case sensitive spaceship operator for strings.
+ * MacOS clang version we use does not implement <=> for std::string
+ * @param Lhs string
+ * @param Rhs string
+ * @return std::strong_ordering indicating relationship between Lhs and Rhs
+ */
+inline auto
+caseSensitiveCompareStrings(const std::string& Lhs, const std::string& Rhs)
+{
+ if (Lhs == Rhs)
+ {
+ return std::strong_ordering::equal;
+ }
+ if (Lhs < Rhs)
+ {
+ return std::strong_ordering::less;
+ }
+ return std::strong_ordering::greater;
+}
+
//////////////////////////////////////////////////////////////////////////
/**