From e9e1bef89c7930a1ccfd78c7166ae8b4af19eb27 Mon Sep 17 00:00:00 2001 From: apio Date: Sat, 25 Feb 2023 16:27:36 +0100 Subject: [PATCH] OwnedPtr, SharedPtr: Add operator bool --- luna/include/luna/OwnedPtr.h | 5 +++++ luna/include/luna/SharedPtr.h | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/luna/include/luna/OwnedPtr.h b/luna/include/luna/OwnedPtr.h index 319b8160..b831f65f 100644 --- a/luna/include/luna/OwnedPtr.h +++ b/luna/include/luna/OwnedPtr.h @@ -59,6 +59,11 @@ template class OwnedPtr return *m_ptr; } + operator bool() const + { + return m_ptr != nullptr; + } + template friend Result> adopt_shared_from_owned(OwnedPtr&&); private: diff --git a/luna/include/luna/SharedPtr.h b/luna/include/luna/SharedPtr.h index 728cc229..020c37a5 100644 --- a/luna/include/luna/SharedPtr.h +++ b/luna/include/luna/SharedPtr.h @@ -99,6 +99,11 @@ template class SharedPtr return *m_ptr; } + operator bool() const + { + return m_ptr != nullptr; + } + private: T* m_ptr; RefCount* m_ref_count;