OwnedPtr, SharedPtr: Add operator bool
All checks were successful
continuous-integration/drone/pr Build is passing

This commit is contained in:
apio 2023-02-25 16:27:36 +01:00
parent ae22321648
commit e9e1bef89c
Signed by: apio
GPG Key ID: B8A7D06E42258954
2 changed files with 10 additions and 0 deletions

View File

@ -59,6 +59,11 @@ template <typename T> class OwnedPtr
return *m_ptr; return *m_ptr;
} }
operator bool() const
{
return m_ptr != nullptr;
}
template <typename Type> friend Result<SharedPtr<Type>> adopt_shared_from_owned(OwnedPtr<Type>&&); template <typename Type> friend Result<SharedPtr<Type>> adopt_shared_from_owned(OwnedPtr<Type>&&);
private: private:

View File

@ -99,6 +99,11 @@ template <typename T> class SharedPtr
return *m_ptr; return *m_ptr;
} }
operator bool() const
{
return m_ptr != nullptr;
}
private: private:
T* m_ptr; T* m_ptr;
RefCount* m_ref_count; RefCount* m_ref_count;