Skip to content

Commit 29b1098

Browse files
committed
jenhash use constructor concepts
1 parent 214b800 commit 29b1098

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

include/spike/crypto/jenkinshash.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ template <typename I> struct JenHash_t {
4747
constexpr JenHash_t() : value_() {}
4848
constexpr JenHash_t(JenHash_t &&) = default;
4949
constexpr JenHash_t(const JenHash_t &) = default;
50-
constexpr explicit JenHash_t(uint32 in) : value_(in) {}
50+
template<class C> requires std::is_integral_v<C>
51+
constexpr JenHash_t(C in) : value_(in) {}
5152
template <size_t n>
5253
constexpr JenHash_t(const char (&input)[n])
5354
: value_(JenkinsHash_<I>({input, n - 1})) {}

include/spike/crypto/jenkinshash3.hpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,9 @@ struct JenHash3 {
138138
constexpr JenHash3() : value_() {}
139139
constexpr JenHash3(JenHash3 &&) = default;
140140
constexpr JenHash3(const JenHash3 &) = default;
141-
constexpr explicit JenHash3(uint32_t in) : value_(in) {}
141+
142+
template<class C> requires std::is_integral_v<C>
143+
constexpr JenHash3(C in) : value_(in) {}
142144
template <size_t n>
143145
constexpr JenHash3(const char (&input)[n])
144146
: value_(JenkinsHash3_({input, n - 1})) {}
@@ -149,6 +151,8 @@ struct JenHash3 {
149151

150152
constexpr operator uint32_t() const { return value_; }
151153

154+
constexpr auto raw() const { return value_; }
155+
152156
private:
153157
uint32_t value_;
154158
};

0 commit comments

Comments
 (0)