Files
chaos/Chaos/Hash/Hasher.hpp
hashlag b5d1f9a6fc
All checks were successful
Chaos Ci / test-and-benchmark (push) Successful in 1m39s
Make CRTP base classes ctors protected
This forbids to create base class instances which direct usage could lead to UB.
2026-01-30 00:44:24 +03:00

45 lines
632 B
C++

#ifndef CHAOS_HASH_HASHER_HPP
#define CHAOS_HASH_HASHER_HPP
namespace Chaos::Hash
{
template<typename T>
class Hasher
{
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);
}
};
} // namespace Chaos::Hash
#endif // CHAOS_HASH_HASHER_HPP