From 29b10981c3931d0a3aab3337e3d2f6095da04049 Mon Sep 17 00:00:00 2001 From: Lukas Cone Date: Thu, 14 Nov 2024 19:24:19 +0100 Subject: [PATCH] jenhash use constructor concepts --- include/spike/crypto/jenkinshash.hpp | 3 ++- include/spike/crypto/jenkinshash3.hpp | 6 +++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/include/spike/crypto/jenkinshash.hpp b/include/spike/crypto/jenkinshash.hpp index e188a94..d7cc2dc 100644 --- a/include/spike/crypto/jenkinshash.hpp +++ b/include/spike/crypto/jenkinshash.hpp @@ -47,7 +47,8 @@ template struct JenHash_t { constexpr JenHash_t() : value_() {} constexpr JenHash_t(JenHash_t &&) = default; constexpr JenHash_t(const JenHash_t &) = default; - constexpr explicit JenHash_t(uint32 in) : value_(in) {} + template requires std::is_integral_v + constexpr JenHash_t(C in) : value_(in) {} template constexpr JenHash_t(const char (&input)[n]) : value_(JenkinsHash_({input, n - 1})) {} diff --git a/include/spike/crypto/jenkinshash3.hpp b/include/spike/crypto/jenkinshash3.hpp index 0939834..9dc58b2 100644 --- a/include/spike/crypto/jenkinshash3.hpp +++ b/include/spike/crypto/jenkinshash3.hpp @@ -138,7 +138,9 @@ struct JenHash3 { constexpr JenHash3() : value_() {} constexpr JenHash3(JenHash3 &&) = default; constexpr JenHash3(const JenHash3 &) = default; - constexpr explicit JenHash3(uint32_t in) : value_(in) {} + + template requires std::is_integral_v + constexpr JenHash3(C in) : value_(in) {} template constexpr JenHash3(const char (&input)[n]) : value_(JenkinsHash3_({input, n - 1})) {} @@ -149,6 +151,8 @@ struct JenHash3 { constexpr operator uint32_t() const { return value_; } + constexpr auto raw() const { return value_; } + private: uint32_t value_; };