From 23454cab467c7ab83ee4f4cc9e19fd528cf64677 Mon Sep 17 00:00:00 2001 From: Brian Gianforcaro Date: Sun, 11 Apr 2021 01:32:23 -0700 Subject: [PATCH] AK: Annotate WeakPtr functions as [[nodiscard]] --- AK/WeakPtr.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/AK/WeakPtr.h b/AK/WeakPtr.h index f4e41281db..1c6a81fc3d 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)