mirror of
https://github.com/SerenityOS/serenity
synced 2024-09-30 05:05:10 +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
|
@ -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…
Reference in a new issue