BLI: add default hash for shared_ptr and reference_wrapper

This makes it easier to use these types as keys in Map, Set and VectorSet.
This commit is contained in:
Jacques Lucke 2021-09-06 12:54:51 +02:00
parent 4d0497bea4
commit e2bbb5b07e
1 changed files with 14 additions and 0 deletions

View File

@ -250,6 +250,20 @@ template<typename T> struct DefaultHash<std::unique_ptr<T>> {
}
};
template<typename T> struct DefaultHash<std::shared_ptr<T>> {
uint64_t operator()(const std::shared_ptr<T> &value) const
{
return get_default_hash(value.get());
}
};
template<typename T> struct DefaultHash<std::reference_wrapper<T>> {
uint64_t operator()(const std::reference_wrapper<T> &value) const
{
return get_default_hash(value.get());
}
};
template<typename T1, typename T2> struct DefaultHash<std::pair<T1, T2>> {
uint64_t operator()(const std::pair<T1, T2> &value) const
{