1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 22:47:44 +00:00

LibJS: Allow GCPtr and NonnullGCPtr to be hashed

This commit is contained in:
Matthew Olsson 2023-02-26 16:06:27 -07:00 committed by Andreas Kling
parent 5141c86587
commit 93a5a54927

View file

@ -6,6 +6,7 @@
#pragma once
#include <AK/Traits.h>
#include <AK/Types.h>
namespace JS {
@ -217,3 +218,23 @@ inline bool operator==(NonnullGCPtr<T> const& a, GCPtr<U> const& b)
}
}
namespace AK {
template<typename T>
struct Traits<JS::GCPtr<T>> : public GenericTraits<JS::GCPtr<T>> {
static unsigned hash(JS::GCPtr<T> const& value)
{
return Traits<T*>::hash(value.ptr());
}
};
template<typename T>
struct Traits<JS::NonnullGCPtr<T>> : public GenericTraits<JS::NonnullGCPtr<T>> {
static unsigned hash(JS::NonnullGCPtr<T> const& value)
{
return Traits<T*>::hash(value.ptr());
}
};
}