Make rexy::hash work on c++ standard containers

This commit is contained in:
rexy712 2022-04-20 15:38:30 -07:00
parent 11ea9db137
commit 7f9a1195fa
2 changed files with 2 additions and 2 deletions

View File

@ -26,7 +26,7 @@ namespace rexy{
template<class T>
struct hash{
constexpr size_t operator()(const T& t, size_t salt)const noexcept{
constexpr size_t operator()(const T& t, size_t salt = 0)const noexcept{
constexpr size_t bytes = sizeof(size_t);
size_t val = static_cast<size_t>(t);
size_t hash = 5381 + salt; //magic hash number

View File

@ -27,7 +27,7 @@ namespace rexy{
//jenkns one at a time hash
template<class Str>
struct string_hash{
constexpr size_t operator()(const Str& s, size_t salt)const noexcept{
constexpr size_t operator()(const Str& s, size_t salt = 0)const noexcept{
size_t hash = salt;
for(size_t i = 0;i < s.length();++i){
hash += s[i];