Replace Hash CRTP base with a concept.

This commit is contained in:
hashlag
2026-08-31 00:05:18 +03:00
parent b769e55753
commit 2f1b5091cd
4 changed files with 13 additions and 28 deletions
+4 -25
View File
@@ -1,38 +1,17 @@
#ifndef CHAOS_HASH_HASH_HPP
#define CHAOS_HASH_HASH_HPP
#include <concepts>
#include <string>
namespace Chaos::Hash
{
template<typename T>
class Hash
concept Hash = requires(T hash)
{
public:
auto GetRawDigest() const
{
return Impl().GetRawDigest();
}
std::string ToHexString() const
{
return Impl().ToHexString();
}
protected:
Hash() = default;
private:
const T & Impl() const
{
return static_cast<const T &>(*this);
}
T & Impl()
{
return static_cast<T &>(*this);
}
hash.GetRawDigest();
{ hash.ToHexString() } -> std::same_as<std::string>;
};
} // namespace Chaos::Hash