From e93319a381bad2f562d8fe631d15fd1aec9771c4 Mon Sep 17 00:00:00 2001 From: Sandu Liviu Catalin Date: Sun, 3 Jul 2016 03:21:29 +0300 Subject: [PATCH] Implement implicit or explicit conversions to boolean for Sqrat weak pointers. --- include/sqrat/sqratUtil.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/include/sqrat/sqratUtil.h b/include/sqrat/sqratUtil.h index 2c08558d..e81eaa4b 100644 --- a/include/sqrat/sqratUtil.h +++ b/include/sqrat/sqratUtil.h @@ -1325,6 +1325,24 @@ public: return *this; } + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + /// Checks if there is an associated managed object + /// + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + operator bool () const + { + return m_Ptr != NULL; + } + + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + /// Checks if there is NOT an associated managed object + /// + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + bool operator!() const + { + return m_Ptr == NULL; + } + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /// Checks whether the managed object exists ///