summaryrefslogtreecommitdiff
path: root/AK/NonnullRefPtr.h
AgeCommit message (Collapse)Author
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: Explicitly delete NonnullRefPtr::operator=(RefPtr).Andreas Kling
This gives us much better error messages when you try to use them. Without this change, it would complain about the absence of functions named ref() and deref() on RefPtr itself. With it, we instead get a "hey, this function is deleted" error. Change operator=(T&) to operator=T(const T&) also, to keep assigning a const T& to a NonnullRefPtr working.
2019-08-02AK: Fix ref leak in NonnullRefPtr::operator=(T&).Andreas Kling
We would leak a ref when assigning a T& to a NonnullRefPtr that already contains that same T.
2019-07-26AK: Fix NonnullRefPtr<T>::operator=(NonnullRefPtr<U>).Andreas Kling
2019-07-25AK: Allow NonnullRefPtr::ptr() when in "unknown" typestate.Andreas Kling
Clang loses the typestate when passing NonnullRefPtr's via lambda captures. This is unfortunate, but not much we can do about it. Allowing ptr() makes it possible to use captured NonnullRefPtrs as you'd expect.
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: Move clang-specific consumable annotation helpers to Platform.hAndreas Kling
2019-07-21AK: Make NonnullRefPtr::operator=(NonnullRefPtr<U>&&) cast incoming pointer.Andreas Kling
Same as the RefPtr issue I just fixed. This makes it possible to assign a NonnullRefPtr<Derived>&& to a NonnullRefPtr<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 weird NonnullRefPtr(NonnullRefPtr&) constructor.Andreas Kling
2019-07-04AK: Move some of LogStream out of line & add overloads for smart pointers.Andreas Kling
2019-06-24NonnullRefPtr: Simplify copy constructors.Andreas Kling
2019-06-24NonnullRefPtr: Some improvements.Andreas Kling
- Delete the default constructor instead of just making it private. It's never valid to create an empty NonnullRefPtr. - Add copy assignment operators. I originally omitted these to force use of .copy_ref() at call sites, but the hassle/gain ratio is minuscule. - Allow calling all the assignment operators in all consumable states. This codifies that it's okay to overwrite a moved-from NonnullRefPtr.
2019-06-21AK: Rename RetainPtr.h => RefPtr.h, Retained.h => NonnullRefPtr.h.Andreas Kling