From 7f9a1195fab4cec91ec4c0af2cc0d0b5c148ad27 Mon Sep 17 00:00:00 2001 From: rexy712 Date: Wed, 20 Apr 2022 15:38:30 -0700 Subject: [PATCH] Make rexy::hash work on c++ standard containers --- include/rexy/hash.hpp | 2 +- include/rexy/string_hash.hpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/rexy/hash.hpp b/include/rexy/hash.hpp index 400f960..7507939 100644 --- a/include/rexy/hash.hpp +++ b/include/rexy/hash.hpp @@ -26,7 +26,7 @@ namespace rexy{ template 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(t); size_t hash = 5381 + salt; //magic hash number diff --git a/include/rexy/string_hash.hpp b/include/rexy/string_hash.hpp index b40594e..e22f300 100644 --- a/include/rexy/string_hash.hpp +++ b/include/rexy/string_hash.hpp @@ -27,7 +27,7 @@ namespace rexy{ //jenkns one at a time hash template 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];