From f2cbed07fe7bcc5646b3424885587c20e35c7fa8 Mon Sep 17 00:00:00 2001 From: Davide Faconti Date: Thu, 1 Feb 2024 14:32:04 +0100 Subject: [PATCH] add std::hash --- data_tamer_cpp/include/data_tamer/types.hpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/data_tamer_cpp/include/data_tamer/types.hpp b/data_tamer_cpp/include/data_tamer/types.hpp index ffdcc0f..7da8dde 100644 --- a/data_tamer_cpp/include/data_tamer/types.hpp +++ b/data_tamer_cpp/include/data_tamer/types.hpp @@ -148,3 +148,18 @@ std::string ToStr(const Schema& schema); [[nodiscard]] uint64_t AddFieldToHash(const TypeField& field, uint64_t hash); } // namespace DataTamer + + +template <> +struct std::hash +{ + std::size_t operator()( const DataTamer::RegistrationID& id ) const + { + // Compute individual hash values for first, second and third + // http://stackoverflow.com/a/1646913/126995 + std::size_t res = 17; + res = res * 31 + hash()( id.first_index ); + res = res * 31 + hash()( id.fields_count ); + return res; + } +};