21 lines
553 B
C++
21 lines
553 B
C++
#pragma once
|
|
|
|
#include <utility>
|
|
#include <type_traits>
|
|
#include <functional>
|
|
|
|
|
|
namespace cruft::hash {
|
|
// A trivial adapter around the `std::hash` that avoids the need to
|
|
// specify the type up front.
|
|
//
|
|
// Useful as a component in more complex hash objects (eg, hash::tuple)
|
|
struct std {
|
|
template <typename ValueT>
|
|
auto operator () (ValueT &&val) const
|
|
{
|
|
using inner_t = ::std::remove_cvref_t<ValueT>;
|
|
return ::std::hash<inner_t> {} (::std::forward<ValueT> (val));
|
|
}
|
|
};
|
|
} |