# HG changeset patch # User Rubidium # Date 2023-05-05 11:58:59 # Node ID 41a10e41285c6095702f9ee43827d448ce009d74 # Parent fc331d731464926e9cfa3134edc2227d5fbe2544 Add: case insensitive string comparator diff --git a/src/string_func.h b/src/string_func.h --- a/src/string_func.h +++ b/src/string_func.h @@ -60,6 +60,11 @@ void StrTrimInPlace(std::string &str); [[nodiscard]] bool StrEqualsIgnoreCase(const std::string_view str1, const std::string_view str2); [[nodiscard]] int StrNaturalCompare(std::string_view s1, std::string_view s2, bool ignore_garbage_at_front = false); +/** Case insensitive comparator for strings, for example for use in std::map. */ +struct CaseInsensitiveComparator { + bool operator()(const std::string_view s1, const std::string_view s2) const { return StrCompareIgnoreCase(s1, s2) < 0; } +}; + /** * Check if a string buffer is empty. *