AK: Remove fallible and unused WeakPtr/Weakable methods
This commit is contained in:
parent
6f1b7c8d50
commit
3d0b2349e6
2 changed files with 5 additions and 32 deletions
25
AK/WeakPtr.h
25
AK/WeakPtr.h
|
|
@ -173,16 +173,6 @@ private:
|
|||
RefPtr<WeakLink> m_link;
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
template<typename U>
|
||||
inline ErrorOr<WeakPtr<U>> Weakable<T>::try_make_weak_ptr() const
|
||||
{
|
||||
if (!m_link)
|
||||
m_link = TRY(adopt_nonnull_ref_or_enomem(new (nothrow) WeakLink(const_cast<T&>(static_cast<T const&>(*this)))));
|
||||
|
||||
return WeakPtr<U>(m_link);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
struct Formatter<WeakPtr<T>> : Formatter<T const*> {
|
||||
ErrorOr<void> format(FormatBuilder& builder, WeakPtr<T> const& value)
|
||||
|
|
@ -191,21 +181,6 @@ struct Formatter<WeakPtr<T>> : Formatter<T const*> {
|
|||
}
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
ErrorOr<WeakPtr<T>> try_make_weak_ptr_if_nonnull(T const* ptr)
|
||||
{
|
||||
if (ptr) {
|
||||
return ptr->template try_make_weak_ptr<T>();
|
||||
}
|
||||
return WeakPtr<T> {};
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
WeakPtr<T> make_weak_ptr_if_nonnull(T const* ptr)
|
||||
{
|
||||
return MUST(try_make_weak_ptr_if_nonnull(ptr));
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
struct Traits<WeakPtr<T>> : public DefaultTraits<WeakPtr<T>> {
|
||||
using PeekType = T*;
|
||||
|
|
|
|||
|
|
@ -6,10 +6,8 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/Assertions.h>
|
||||
#include <AK/RefCounted.h>
|
||||
#include <AK/RefPtr.h>
|
||||
#include <AK/StdLibExtras.h>
|
||||
|
||||
namespace AK {
|
||||
|
||||
|
|
@ -61,11 +59,11 @@ public:
|
|||
template<typename U = T>
|
||||
WeakPtr<U> make_weak_ptr() const
|
||||
{
|
||||
return MUST(try_make_weak_ptr<U>());
|
||||
}
|
||||
if (!m_link)
|
||||
m_link = adopt_ref(*new (nothrow) WeakLink(const_cast<T&>(static_cast<T const&>(*this))));
|
||||
|
||||
template<typename U = T>
|
||||
ErrorOr<WeakPtr<U>> try_make_weak_ptr() const;
|
||||
return m_link;
|
||||
}
|
||||
|
||||
protected:
|
||||
Weakable() = default;
|
||||
|
|
@ -75,7 +73,7 @@ protected:
|
|||
revoke_weak_ptrs();
|
||||
}
|
||||
|
||||
void revoke_weak_ptrs()
|
||||
void revoke_weak_ptrs() const
|
||||
{
|
||||
if (auto link = move(m_link))
|
||||
link->revoke();
|
||||
|
|
|
|||
Loading…
Reference in a new issue