From c6f9fbd244babdb347bb156fbb6c8582268e0e92 Mon Sep 17 00:00:00 2001 From: lisyarus Date: Tue, 21 May 2024 13:21:01 +0300 Subject: [PATCH] Add util::hash_all for creating a hash out of a bunch of objects --- libs/util/include/psemek/util/hash.hpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/libs/util/include/psemek/util/hash.hpp b/libs/util/include/psemek/util/hash.hpp index 2f8a77cd..3bbfcdd3 100644 --- a/libs/util/include/psemek/util/hash.hpp +++ b/libs/util/include/psemek/util/hash.hpp @@ -36,6 +36,15 @@ namespace psemek::util } }; + template + constexpr std::size_t hash_all(T const & ... x) + { + any_hash hash; + std::size_t seed = 0; + (hash_combine(seed, hash(x)), ...); + return seed; + } + } namespace std