mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 15:28:11 +00:00
AK: Make it possible to use HashMap<K, NonnullOwnPtr>::get()
Add the concept of a PeekType to Traits<T>. This is the type we'll return (wrapped in an Optional) from HashMap::get(). The PeekType for OwnPtr<T> and NonnullOwnPtr<T> is const T*, which means that HashMap::get() will return an Optional<const T*> for maps-of-those.
This commit is contained in:
parent
f75b1127b2
commit
fdcff7d15e
6 changed files with 40 additions and 2 deletions
|
@ -164,6 +164,7 @@ private:
|
|||
|
||||
template<typename T>
|
||||
struct Traits<OwnPtr<T>> : public GenericTraits<OwnPtr<T>> {
|
||||
using PeekType = const T*;
|
||||
static unsigned hash(const OwnPtr<T>& p) { return (unsigned)p.ptr(); }
|
||||
static void dump(const OwnPtr<T>& p) { kprintf("%p", p.ptr()); }
|
||||
static bool equals(const OwnPtr<T>& a, const OwnPtr<T>& b) { return a.ptr() == b.ptr(); }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue