1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 09:47:35 +00:00

AK+Kernel: Add an OOM-fallible try variant make_weak_ptr()

This will allow us to propagate allocation errors that may be raised by
the construction of the WeakLink.
This commit is contained in:
Idan Horowitz 2022-02-13 21:16:21 +02:00 committed by Andreas Kling
parent d6ea6c39a7
commit 98c20b65cc
3 changed files with 28 additions and 14 deletions

View file

@ -106,7 +106,9 @@ private:
public:
template<typename U = T>
WeakPtr<U> make_weak_ptr() const;
WeakPtr<U> make_weak_ptr() const { return MUST(try_make_weak_ptr<U>()); }
template<typename U = T>
ErrorOr<WeakPtr<U>> try_make_weak_ptr() const;
protected:
Weakable() = default;