summaryrefslogtreecommitdiff
path: root/AK/RefPtr.h
AgeCommit message (Collapse)Author
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-08-03AK: Remove two redundant RefPtr constructors.Andreas Kling
We already have constructors for "const T*" and "const T&" so we don't need to have non-const variants.
2019-08-02AK: Simplify RefPtr and NonnullRefPtr's leak_ref() functionsAndreas Kling
Use AK::exchange() to switch out the internal storage. Also mark these functions with [[nodiscard]] to provoke an compile-time error if they are called without using the return value.
2019-08-02AK: Add anti-null assertions in RefPtr.Andreas Kling
This gives us better error messages when dereferencing null RefPtrs.
2019-08-02AK: Fix ref leaks in RefPtr assignment operators.Andreas Kling
Many of the RefPtr assignment operators would cause ref leaks when we call them to assign a pointer that's already the one kept.
2019-07-21AK: RefPtr::operator=(RefPtr<U>&&) needs to cast the incoming pointer.Andreas Kling
Otherwise it's not possible to assign a RefPtr<Derived>&& to a RefPtr<Base>.
2019-07-11AK: Delete bad pointer assignment operators and constructors.Andreas Kling
We shouldn't allow constructing e.g an OwnPtr from a RefPtr, and similar conversions. Instead just delete those functions so the compiler whines loudly if you try to use them. This patch also deletes constructing OwnPtr from a WeakPtr, even though that *may* be a valid thing to do, it's sufficiently weird that we can make the client jump through some hoops if he really wants it. :^)
2019-07-11AK: Remove copy_ref().Andreas Kling
This patch removes copy_ref() from RefPtr and NonnullRefPtr. This means that it's now okay to simply copy these smart pointers instead: - RefPtr = RefPtr // Okay! - RefPtr = NonnullRefPtr // Okay! - NonnullRefPtr = NonnullRefPtr // Okay! - NonnullRefPtr = RefPtr // Not okay, since RefPtr can be null.
2019-07-11AK: Remove use of copy_ref().Andreas Kling
2019-07-11AK: Make it more more pleasant to copy RefPtr's.Andreas Kling
I had a silly ambition that we would avoid unnecessary ref count churn by forcing explicit use of "copy_ref()" wherever a copy was actually needed. This was making RefPtr a bit clunky to work with, for no real benefit. This patch adds the missing copy construction/assignment stuff to RefPtr.
2019-07-11AK: Remove weird RefPtr(RefPtr&) constructor.Andreas Kling
2019-07-04AK: Move some of LogStream out of line & add overloads for smart pointers.Andreas Kling
2019-06-21AK: Rename RetainPtr.h => RefPtr.h, Retained.h => NonnullRefPtr.h.Andreas Kling