From 23d3af21c66852c1262031cad16aedab3e73a5ab Mon Sep 17 00:00:00 2001 From: Dander7BD Date: Thu, 28 Nov 2013 11:15:25 +0100 Subject: [PATCH] Added comparison operators to UniquePointer and UniqueArray operator == operator != --- Code/Misc/Utilities-InlineImpl.h | 24 ++++++++++++++++++++++++ Code/Misc/Utilities.h | 12 ++++++++++++ 2 files changed, 36 insertions(+) diff --git a/Code/Misc/Utilities-InlineImpl.h b/Code/Misc/Utilities-InlineImpl.h index dc047153..cd8946d3 100644 --- a/Code/Misc/Utilities-InlineImpl.h +++ b/Code/Misc/Utilities-InlineImpl.h @@ -90,6 +90,18 @@ namespace Utility return this->ownedInstance != NULL; } + template + bool UniquePointer::operator == ( Type *stray ) const + { + return this->ownedInstance == stray; + } + + template + bool UniquePointer::operator != ( Type *stray ) const + { + return this->ownedInstance != stray; + } + template Type* UniquePointer::Release() { @@ -149,6 +161,18 @@ namespace Utility return this->ownedArray != NULL; } + template + bool UniqueArray::operator == ( Type *stray ) const + { + return this->ownedArray == stray; + } + + template + bool UniqueArray::operator != ( Type *stray ) const + { + return this->ownedArray != stray; + } + template Type* UniqueArray::Release() { diff --git a/Code/Misc/Utilities.h b/Code/Misc/Utilities.h index a07143cf..d6127d73 100644 --- a/Code/Misc/Utilities.h +++ b/Code/Misc/Utilities.h @@ -56,6 +56,12 @@ namespace Utility //! If true, this UniquePointer have a current ownership/responsibility of a dynamic instance. operator bool () const; + //! @return true if this ownedInstance matches with stray + bool operator == ( Type *stray ) const; + + //! @return false if this ownedInstance matches with stray + bool operator != ( Type *stray ) const; + //! This UniquePointer drops all claims of ownership/responsibility and returns the dynamic instance. Now it is your responsibility to delete. Type* Release(); @@ -96,6 +102,12 @@ namespace Utility //! If true, this UniqueArray have a current ownership/responsibility of a dynamic instance. operator bool () const; + //! @return true if this ownedInstance matches with stray + bool operator == ( Type *stray ) const; + + //! @return false if this ownedInstance matches with stray + bool operator != ( Type *stray ) const; + //! This UniqueArray drops all claims of ownership/responsibility and returns the dynamic array. Now it is your responsibility to delete. Type* Release();