From 0e026808036f59d3ea4e5954b1a19fcfcb9a9702 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Mon, 8 May 2023 16:31:58 -0600 Subject: [PATCH] [hash] Add hash impl for integers Part of https://github.com/harfbuzz/harfbuzz/issues/4227 --- src/hb-algs.hh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/hb-algs.hh b/src/hb-algs.hh index da383e050..4bebad771 100644 --- a/src/hb-algs.hh +++ b/src/hb-algs.hh @@ -236,7 +236,11 @@ struct private: template constexpr auto - impl (const T& v, hb_priority<1>) const HB_RETURN (uint32_t, hb_deref (v).hash ()) + impl (const T& v, hb_priority<2>) const HB_RETURN (uint32_t, hb_deref (v).hash ()) + + // Horrible: std:hash() of integers seems to be identity in gcc / clang?! + template constexpr auto + impl (const T& v, hb_priority<1>) const HB_RETURN (uint32_t, v * 2654435761u) template constexpr auto impl (const T& v, hb_priority<0>) const HB_RETURN (uint32_t, std::hash>{} (hb_deref (v)))