mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 07:30:19 +00:00
AK: Add Optional-like value()/has_value() getters to WeakPtr
This commit is contained in:
parent
c373c2deb0
commit
e591c604de
Notes:
sideshowbarker
2024-07-17 08:38:37 +09:00
Author: https://github.com/alimpfard Commit: https://github.com/SerenityOS/serenity/commit/e591c604de Pull-request: https://github.com/SerenityOS/serenity/pull/16396 Reviewed-by: https://github.com/ADKaster Reviewed-by: https://github.com/awesomekling ✅
1 changed files with 5 additions and 0 deletions
|
@ -149,9 +149,14 @@ public:
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
[[nodiscard]] T const* value() const { return unsafe_ptr(); }
|
||||
[[nodiscard]] T* value() { return unsafe_ptr(); }
|
||||
|
||||
operator bool() const { return m_link ? !m_link->is_null() : false; }
|
||||
|
||||
[[nodiscard]] bool is_null() const { return !m_link || m_link->is_null(); }
|
||||
[[nodiscard]] bool has_value() const { return !is_null(); }
|
||||
|
||||
void clear() { m_link = nullptr; }
|
||||
|
||||
[[nodiscard]] RefPtr<WeakLink> take_link() { return move(m_link); }
|
||||
|
|
Loading…
Reference in a new issue