Skip to content

Commit

Permalink
jenhash use constructor concepts
Browse files Browse the repository at this point in the history
  • Loading branch information
PredatorCZ committed Nov 14, 2024
1 parent 214b800 commit 29b1098
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
3 changes: 2 additions & 1 deletion include/spike/crypto/jenkinshash.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ template <typename I> 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<class C> requires std::is_integral_v<C>
constexpr JenHash_t(C in) : value_(in) {}
template <size_t n>
constexpr JenHash_t(const char (&input)[n])
: value_(JenkinsHash_<I>({input, n - 1})) {}
Expand Down
6 changes: 5 additions & 1 deletion include/spike/crypto/jenkinshash3.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<class C> requires std::is_integral_v<C>
constexpr JenHash3(C in) : value_(in) {}
template <size_t n>
constexpr JenHash3(const char (&input)[n])
: value_(JenkinsHash3_({input, n - 1})) {}
Expand All @@ -149,6 +151,8 @@ struct JenHash3 {

constexpr operator uint32_t() const { return value_; }

constexpr auto raw() const { return value_; }

private:
uint32_t value_;
};
Expand Down

0 comments on commit 29b1098

Please sign in to comment.