Update SmartPointer.h
Add spaces and fix title case, fix abbreviations
This commit is contained in:
parent
38263c8270
commit
5338a99b37
|
@ -1,12 +1,12 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
//The template class definition for smart pointer
|
// The template class definition for smart pointer
|
||||||
template<class _Ty>
|
template<class _Ty>
|
||||||
class AUTO_PTR
|
class AUTO_PTR
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef _Ty element_type;
|
typedef _Ty element_type;
|
||||||
//ctor
|
// CTOR
|
||||||
explicit AUTO_PTR(_Ty *pVal = 0) throw() :
|
explicit AUTO_PTR(_Ty *pVal = 0) throw() :
|
||||||
m_Owns(pVal != 0),
|
m_Owns(pVal != 0),
|
||||||
m_AutoPtr(pVal)
|
m_AutoPtr(pVal)
|
||||||
|
@ -14,14 +14,14 @@ public:
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
//copy ctor
|
// Copy CTOR
|
||||||
AUTO_PTR(const AUTO_PTR<_Ty>& ptrCopy) throw() :
|
AUTO_PTR(const AUTO_PTR<_Ty>& ptrCopy) throw() :
|
||||||
m_Owns(ptrCopy.m_Owns),
|
m_Owns(ptrCopy.m_Owns),
|
||||||
m_AutoPtr(ptrCopy.release())
|
m_AutoPtr(ptrCopy.release())
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
//overloading = operator
|
// Overloading = operator
|
||||||
AUTO_PTR<_Ty>& operator=(AUTO_PTR<_Ty>& ptrCopy) throw()
|
AUTO_PTR<_Ty>& operator=(AUTO_PTR<_Ty>& ptrCopy) throw()
|
||||||
{
|
{
|
||||||
if (this != &ptrCopy)
|
if (this != &ptrCopy)
|
||||||
|
@ -42,7 +42,7 @@ public:
|
||||||
}
|
}
|
||||||
return (*this);
|
return (*this);
|
||||||
}
|
}
|
||||||
//dtor
|
// DTOR
|
||||||
~AUTO_PTR()
|
~AUTO_PTR()
|
||||||
{
|
{
|
||||||
if (m_Owns)
|
if (m_Owns)
|
||||||
|
@ -50,25 +50,25 @@ public:
|
||||||
delete m_AutoPtr;
|
delete m_AutoPtr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//overloading * operator
|
// Overloading * operator
|
||||||
_Ty& operator*() const throw()
|
_Ty& operator*() const throw()
|
||||||
{
|
{
|
||||||
return (*get());
|
return (*get());
|
||||||
}
|
}
|
||||||
|
|
||||||
//overloading -> operator
|
// Overloading -> operator
|
||||||
_Ty *operator->() const throw()
|
_Ty *operator->() const throw()
|
||||||
{
|
{
|
||||||
return (get());
|
return (get());
|
||||||
}
|
}
|
||||||
|
|
||||||
//function to get the pointer to the class
|
// Function to get the pointer to the class
|
||||||
_Ty *get() const throw()
|
_Ty *get() const throw()
|
||||||
{
|
{
|
||||||
return (m_AutoPtr);
|
return (m_AutoPtr);
|
||||||
}
|
}
|
||||||
|
|
||||||
//function to get the pointer to the class and take ownership
|
// Function to get the pointer to the class and take ownership
|
||||||
_Ty *release() const throw()
|
_Ty *release() const throw()
|
||||||
{
|
{
|
||||||
((AUTO_PTR<_Ty> *)this)->m_Owns = false;
|
((AUTO_PTR<_Ty> *)this)->m_Owns = false;
|
||||||
|
|
Loading…
Reference in New Issue