From 55ed2b3b4fac69d7d4bcb62f312b1fd233626577 Mon Sep 17 00:00:00 2001 From: Manuel Nickschas Date: Mon, 15 Oct 2018 21:22:04 +0200 Subject: [PATCH 1/1] types: Add STL-compliant Hash functor for Qt types In order to use Qt types with std::unordered_set (and map), a compatible hash function needs to be provided. Provide a generic Hash functor that just uses the qHash() function for the given type. This can be used as follows: std::unordered_set> set; --- src/common/types.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/common/types.h b/src/common/types.h index a806c58f..0816223d 100644 --- a/src/common/types.h +++ b/src/common/types.h @@ -225,6 +225,16 @@ QDataStream& operator>>(QDataStream& in, T& value) return in; } +// STL-compliant hash functor for Qt types +template +struct Hash +{ + uint operator()(const T& t) const + { + return qHash(t); + } +}; + // Exceptions /** -- 2.20.1