mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 14:17:36 +00:00
LibJS: Allow GCPtr and NonnullGCPtr to be hashed
This commit is contained in:
parent
5141c86587
commit
93a5a54927
1 changed files with 21 additions and 0 deletions
|
@ -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());
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue