diff options
author | Idan Horowitz <idan.horowitz@gmail.com> | 2022-02-13 21:16:21 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2022-02-13 23:02:57 +0100 |
commit | 98c20b65cc1e436e805f066bf2b007ebf0a798ec (patch) | |
tree | 0badab0a7b15a112d5cdfa5fee1d54c636b7fc09 /AK/Weakable.h | |
parent | d6ea6c39a77c092ef32ffec2055065eed93f9daf (diff) | |
download | serenity-98c20b65cc1e436e805f066bf2b007ebf0a798ec.zip |
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.
Diffstat (limited to 'AK/Weakable.h')
-rw-r--r-- | AK/Weakable.h | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/AK/Weakable.h b/AK/Weakable.h index c3ee850520..c800be9205 100644 --- a/AK/Weakable.h +++ b/AK/Weakable.h @@ -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; |