summaryrefslogtreecommitdiff
path: root/smartptr.h
diff options
context:
space:
mode:
authorJeffrey Walton <noloader@gmail.com>2017-03-01 06:10:06 -0500
committerJeffrey Walton <noloader@gmail.com>2017-03-01 06:10:06 -0500
commit5efb019d8bdc593b3c1a0b57d615b170c7dab02a (patch)
treee2c10e737542fd13ea50b58480e0791bbc455e47 /smartptr.h
parent5fb2f5d45b9bb2cd86db5d01f4b30d606a2a4c80 (diff)
downloadcryptopp-git-5efb019d8bdc593b3c1a0b57d615b170c7dab02a.tar.gz
Add C++ nullptr support (Issue 383)
Diffstat (limited to 'smartptr.h')
-rw-r--r--smartptr.h20
1 files changed, 10 insertions, 10 deletions
diff --git a/smartptr.h b/smartptr.h
index 605be2ed..cc7874fb 100644
--- a/smartptr.h
+++ b/smartptr.h
@@ -20,11 +20,11 @@ NAMESPACE_BEGIN(CryptoPP)
template <class T> class simple_ptr
{
public:
- simple_ptr(T *p = NULL) : m_p(p) {}
+ simple_ptr(T *p = NULLPTR) : m_p(p) {}
~simple_ptr()
{
delete m_p;
- *((volatile T**)&m_p) = NULL;
+ m_p = NULLPTR;
}
T *m_p;
@@ -39,7 +39,7 @@ public:
template <class T> class member_ptr
{
public:
- explicit member_ptr(T *p = NULL) : m_p(p) {}
+ explicit member_ptr(T *p = NULLPTR) : m_p(p) {}
~member_ptr();
@@ -55,7 +55,7 @@ public:
T* release()
{
T *old_p = m_p;
- *((volatile T**)&m_p) = NULL;
+ m_p = NULLPTR;
return old_p;
}
@@ -80,9 +80,9 @@ template<class T> class value_ptr : public member_ptr<T>
{
public:
value_ptr(const T &obj) : member_ptr<T>(new T(obj)) {}
- value_ptr(T *p = NULL) : member_ptr<T>(p) {}
+ value_ptr(T *p = NULLPTR) : member_ptr<T>(p) {}
value_ptr(const value_ptr<T>& rhs)
- : member_ptr<T>(rhs.m_p ? new T(*rhs.m_p) : NULL) {}
+ : member_ptr<T>(rhs.m_p ? new T(*rhs.m_p) : NULLPTR) {}
value_ptr<T>& operator=(const value_ptr<T>& rhs);
bool operator==(const value_ptr<T>& rhs)
@@ -94,7 +94,7 @@ public:
template <class T> value_ptr<T>& value_ptr<T>::operator=(const value_ptr<T>& rhs)
{
T *old_p = this->m_p;
- this->m_p = rhs.m_p ? new T(*rhs.m_p) : NULL;
+ this->m_p = rhs.m_p ? new T(*rhs.m_p) : NULLPTR;
delete old_p;
return *this;
}
@@ -109,9 +109,9 @@ template<class T> class clonable_ptr : public member_ptr<T>
{
public:
clonable_ptr(const T &obj) : member_ptr<T>(obj.Clone()) {}
- clonable_ptr(T *p = NULL) : member_ptr<T>(p) {}
+ clonable_ptr(T *p = NULLPTR) : member_ptr<T>(p) {}
clonable_ptr(const clonable_ptr<T>& rhs)
- : member_ptr<T>(rhs.m_p ? rhs.m_p->Clone() : NULL) {}
+ : member_ptr<T>(rhs.m_p ? rhs.m_p->Clone() : NULLPTR) {}
clonable_ptr<T>& operator=(const clonable_ptr<T>& rhs);
};
@@ -119,7 +119,7 @@ public:
template <class T> clonable_ptr<T>& clonable_ptr<T>::operator=(const clonable_ptr<T>& rhs)
{
T *old_p = this->m_p;
- this->m_p = rhs.m_p ? rhs.m_p->Clone() : NULL;
+ this->m_p = rhs.m_p ? rhs.m_p->Clone() : NULLPTR;
delete old_p;
return *this;
}