Commit graph

8 commits

Author SHA1 Message Date
Andreas Kling fa6f601170 AK: RefPtr::operator=(RefPtr<U>&&) needs to cast the incoming pointer.
Otherwise it's not possible to assign a RefPtr<Derived>&& to a RefPtr<Base>.
2019-07-21 11:37:24 +02:00
Andreas Kling 25e3d46502 AK: Delete bad pointer assignment operators and constructors.
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-11 16:50:30 +02:00
Andreas Kling eb64a4ca60 AK: Remove copy_ref().
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-11 16:05:51 +02:00
Andreas Kling b0372883ff AK: Remove use of copy_ref(). 2019-07-11 15:45:11 +02:00
Andreas Kling 560d037c41 AK: Make it more more pleasant to copy RefPtr's.
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-11 15:38:38 +02:00
Andreas Kling 32fb7ecef4 AK: Remove weird RefPtr(RefPtr&) constructor. 2019-07-11 15:19:16 +02:00
Andreas Kling 1b013ba699 AK: Move some of LogStream out of line & add overloads for smart pointers. 2019-07-04 07:05:58 +02:00
Andreas Kling 550b0b062b AK: Rename RetainPtr.h => RefPtr.h, Retained.h => NonnullRefPtr.h. 2019-06-21 18:45:59 +02:00
Renamed from AK/RetainPtr.h (Browse further)