1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 23:17:45 +00:00

AK: Ensure we never use OwnPtr<> with RefCounted types

This commit is contained in:
Sergey Bugaev 2020-06-12 16:30:30 +03:00 committed by Andreas Kling
parent 62d1ac63e8
commit 0466810638
3 changed files with 15 additions and 1 deletions

View file

@ -27,16 +27,18 @@
#pragma once
#include <AK/NonnullOwnPtr.h>
#include <AK/RefCounted.h>
namespace AK {
template<typename T>
class OwnPtr {
public:
OwnPtr() {}
OwnPtr() { }
explicit OwnPtr(T* ptr)
: m_ptr(ptr)
{
static_assert(!is_ref_counted((const T*)nullptr), "Use RefPtr<> for RefCounted types");
}
OwnPtr(OwnPtr&& other)
: m_ptr(other.leak_ptr())