mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-21 20:15:17 +00:00
AK: Make WeakPtr<T>::value() return NonnullRefPtr<T>
This API is only used by Jakt to implement weak reference unwrapping. By making it return a NonnullRefPtr, it can be assigned to anything that accepts a NonnullRefPtr, unlike the previous T* return type (since that can also be null).
This commit is contained in:
parent
675713ad8e
commit
ed3420dc10
Notes:
sideshowbarker
2024-07-17 07:20:57 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/ed3420dc10
1 changed files with 5 additions and 2 deletions
|
@ -149,8 +149,11 @@ public:
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
[[nodiscard]] T const* value() const { return unsafe_ptr(); }
|
||||
[[nodiscard]] T* value() { return unsafe_ptr(); }
|
||||
[[nodiscard]] NonnullRefPtr<T> value() const
|
||||
{
|
||||
VERIFY(has_value());
|
||||
return *unsafe_ptr();
|
||||
}
|
||||
|
||||
operator bool() const { return m_link ? !m_link->is_null() : false; }
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue