Replace Hash CRTP base with a concept.
This commit is contained in:
+4
-25
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user