mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 00:17:46 +00:00
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. :^)
This commit is contained in:
parent
01998a10e3
commit
25e3d46502
3 changed files with 36 additions and 0 deletions
|
@ -6,6 +6,9 @@
|
|||
|
||||
namespace AK {
|
||||
|
||||
template<typename T>
|
||||
class OwnPtr;
|
||||
|
||||
template<typename T>
|
||||
class RefPtr {
|
||||
public:
|
||||
|
@ -86,6 +89,11 @@ public:
|
|||
}
|
||||
RefPtr(std::nullptr_t) {}
|
||||
|
||||
template<typename U>
|
||||
RefPtr(const OwnPtr<U>&) = delete;
|
||||
template<typename U>
|
||||
RefPtr& operator=(const OwnPtr<U>&) = delete;
|
||||
|
||||
RefPtr& operator=(RefPtr&& other)
|
||||
{
|
||||
if (this != &other) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue