Implements ConstString comparison with other string types.
continuous-integration/drone/push Build is failing Details

This commit is contained in:
Deukhoofd 2020-02-27 16:35:02 +01:00
parent efec26fe68
commit e6599e2b5b
Signed by: Deukhoofd
GPG Key ID: ADF2E9256009EDCE
1 changed files with 6 additions and 1 deletions

View File

@ -19,7 +19,8 @@ namespace Arbutils {
inline static constexpr char charToLower(const char c) { return (c >= 'A' && c <= 'Z') ? c + ('a' - 'A') : c; }
inline static uint32_t constexpr LowercaseHash(char const* input) {
return charToLower(*input) ? static_cast<uint32_t>(charToLower(*input)) + 33 * LowercaseHash(input + 1) : 5381;
return charToLower(*input) ? static_cast<uint32_t>(charToLower(*input)) + 33 * LowercaseHash(input + 1)
: 5381;
}
inline static int constexpr Length(const char* str) { return *str ? 1 + Length(str + 1) : 0; }
@ -51,6 +52,10 @@ namespace Arbutils {
inline constexpr bool operator==(const ConstString& rhs) const { return _hash == rhs._hash; }
inline constexpr bool operator!=(const ConstString& rhs) const { return _hash != rhs._hash; }
inline constexpr bool operator==(const std::string& rhs) const { return _hash == Hash(rhs.c_str()); }
inline constexpr bool operator!=(const std::string& rhs) const { return _hash != Hash(rhs.c_str()); }
inline constexpr bool operator==(const char* rhs) const { return _hash == Hash(rhs); }
inline constexpr bool operator!=(const char* rhs) const { return _hash != Hash(rhs); }
};
}