Added comparison operators to UniquePointer and UniqueArray

operator ==
operator !=
This commit is contained in:
Dander7BD 2013-11-28 11:15:25 +01:00 committed by Erik Persson
parent b06a03a543
commit 3a3d6fb151
2 changed files with 36 additions and 0 deletions

View File

@ -98,6 +98,18 @@ namespace Utility
return this->ownedInstance != NULL;
}
template<typename Type>
bool UniquePointer<Type>::operator == ( Type *stray ) const
{
return this->ownedInstance == stray;
}
template<typename Type>
bool UniquePointer<Type>::operator != ( Type *stray ) const
{
return this->ownedInstance != stray;
}
template<typename Type>
Type* UniquePointer<Type>::Release()
{
@ -165,6 +177,18 @@ namespace Utility
return this->ownedArray != NULL;
}
template<typename Type>
bool UniqueArray<Type>::operator == ( Type *stray ) const
{
return this->ownedArray == stray;
}
template<typename Type>
bool UniqueArray<Type>::operator != ( Type *stray ) const
{
return this->ownedArray != stray;
}
template<typename Type>
Type* UniqueArray<Type>::Release()
{

View File

@ -60,6 +60,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();
@ -104,6 +110,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();