summaryrefslogtreecommitdiff
path: root/AK/NonnullOwnPtr.h
AgeCommit message (Collapse)Author
2019-08-14AK: Use int_hash() to generate less idiotic hashes for {Nonnull,}OwnPtrAndreas Kling
2019-08-14AK: Make it possible to use HashMap<K, NonnullOwnPtr>::get()Andreas Kling
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.
2019-07-25AK: Simplify NonnullPtrVector template a bit.Andreas Kling
Add an "ElementType" typedef to NonnullOwnPtr and NonnullRefPtr to allow clients to easily find the pointee type. Then use this to remove a template argument from NonnullPtrVector. :^)
2019-07-24AK: Add NonnullOwnPtr.Andreas Kling
This is just like OwnPtr (also single-owner), except it cannot be null. NonnullOwnPtr is perfect as the return type of functions that never need to return nullptr. It's also useful as an argument type to encode the fact that the argument must not be nullptr. The make<Foo>() helper is changed to return NonnullOwnPtr<Foo>. Note: You can move() out of a NonnullOwnPtr, and after that the object is in an invalid state. Internally it will be a nullptr at this point, so we'll still catch misuse, but the only thing that should be done in this state is running the destructor. I've used consumable annotations to generate some warnings when using a NonnullOwnPtr after moving from it, but these only work when compiling with clang, so be aware of that.