diff --git a/AK/WeakPtr.h b/AK/WeakPtr.h index f4e41281db7..1c6a81fc3d2 100644 --- a/AK/WeakPtr.h +++ b/AK/WeakPtr.h @@ -143,7 +143,7 @@ public: return *this; } - RefPtr strong_ref() const + [[nodiscard]] RefPtr strong_ref() const { // This only works with RefCounted objects, but it is the only // safe way to get a strong reference from a WeakPtr. Any code @@ -169,7 +169,7 @@ public: operator T*() { return unsafe_ptr(); } #endif - T* unsafe_ptr() const + [[nodiscard]] T* unsafe_ptr() const { T* ptr = nullptr; m_link.do_while_locked([&](WeakLink* link) { @@ -181,10 +181,10 @@ public: operator bool() const { return m_link ? !m_link->is_null() : false; } - bool is_null() const { return !m_link || m_link->is_null(); } + [[nodiscard]] bool is_null() const { return !m_link || m_link->is_null(); } void clear() { m_link = nullptr; } - RefPtr take_link() { return move(m_link); } + [[nodiscard]] RefPtr take_link() { return move(m_link); } private: WeakPtr(const RefPtr& link)