LibGC: Add Ptr::as_nonnull()

Convert from a GC::Ptr to a GC::Ref directly, instead of having to write
`GC::Ref { *thing }`.
This commit is contained in:
Sam Atkins 2025-08-22 10:28:57 +01:00 committed by Andreas Kling
commit e174215845
Notes: github-actions[bot] 2025-08-29 09:58:48 +00:00

View file

@ -183,6 +183,12 @@ public:
operator T*() const { return m_ptr; } operator T*() const { return m_ptr; }
Ref<T> as_nonnull()
{
VERIFY(m_ptr);
return *m_ptr;
}
private: private:
T* m_ptr { nullptr }; T* m_ptr { nullptr };
}; };