1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-28 14:15:07 +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:
Andreas Kling 2019-08-14 11:47:38 +02:00
parent f75b1127b2
commit fdcff7d15e
6 changed files with 40 additions and 2 deletions

View file

@ -68,7 +68,7 @@ public:
void dump() const { m_table.dump(); }
Optional<V> get(const K& key) const
Optional<typename Traits<V>::PeekType> get(const K& key) const
{
auto it = find(key);
if (it == end())