From 93a5a54927388b9d5e8c9351eb2112a398a60145 Mon Sep 17 00:00:00 2001 From: Matthew Olsson Date: Sun, 26 Feb 2023 16:06:27 -0700 Subject: [PATCH] LibJS: Allow GCPtr and NonnullGCPtr to be hashed --- Userland/Libraries/LibJS/Heap/GCPtr.h | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/Userland/Libraries/LibJS/Heap/GCPtr.h b/Userland/Libraries/LibJS/Heap/GCPtr.h index 8a821167f6..398a31cb99 100644 --- a/Userland/Libraries/LibJS/Heap/GCPtr.h +++ b/Userland/Libraries/LibJS/Heap/GCPtr.h @@ -6,6 +6,7 @@ #pragma once +#include #include namespace JS { @@ -217,3 +218,23 @@ inline bool operator==(NonnullGCPtr const& a, GCPtr const& b) } } + +namespace AK { + +template +struct Traits> : public GenericTraits> { + static unsigned hash(JS::GCPtr const& value) + { + return Traits::hash(value.ptr()); + } +}; + +template +struct Traits> : public GenericTraits> { + static unsigned hash(JS::NonnullGCPtr const& value) + { + return Traits::hash(value.ptr()); + } +}; + +}