Replace Hasher CRTP base with a concept.
Chaos Ci / test (push) Successful in 3m17s
Chaos Ci / benchmark (push) Successful in 1m54s

This commit is contained in:
hashlag
2026-08-31 01:22:07 +03:00
parent 2f1b5091cd
commit b03fddd40b
5 changed files with 18 additions and 37 deletions
+8 -31
View File
@@ -1,42 +1,19 @@
#ifndef CHAOS_HASH_HASHER_HPP
#define CHAOS_HASH_HASHER_HPP
#include <cstdint>
#include "Hash.hpp"
namespace Chaos::Hash
{
template<typename T>
class Hasher
concept Hasher = requires(T hasher, uint8_t * begin, uint8_t * end)
{
public:
void Reset()
{
Impl().Reset();
}
template<typename InputIt>
void Update(InputIt begin, InputIt end)
{
Impl().Update(begin, end);
}
auto Finish()
{
return Impl().Finish();
}
protected:
Hasher() = default;
private:
const T & Impl() const
{
return static_cast<const T &>(*this);
}
T & Impl()
{
return static_cast<T &>(*this);
}
hasher.Reset();
hasher.Update(begin, end);
{ hasher.Finish() } -> Hash;
};
} // namespace Chaos::Hash