6#ifndef CRYPTOPP_SMARTPTR_H
7#define CRYPTOPP_SMARTPTR_H
40 explicit member_ptr(T *p = NULLPTR) : m_p(p) {}
44 const T& operator*()
const {
return *m_p; }
45 T& operator*() {
return *m_p; }
47 const T* operator->()
const {
return m_p; }
48 T* operator->() {
return m_p; }
50 const T* get()
const {
return m_p; }
51 T* get() {
return m_p; }
60 void reset(T *p = NULLPTR);
87 return (!this->m_p && !rhs.m_p) || (this->m_p && rhs.m_p && *this->m_p == *rhs.m_p);
94 this->m_p = rhs.m_p ?
new T(*rhs.m_p) : NULLPTR;
117 T *old_p = this->m_p;
118 this->m_p = rhs.m_p ? rhs.m_p->Clone() : NULLPTR;
138 const T& operator*()
const {
return *m_p; }
139 T& operator*() {
return *m_p; }
141 const T* operator->()
const {
return m_p; }
142 T* operator->() {
return get(); }
144 const T* get()
const {
return m_p; }
147 void attach(
const T &p);
159 m_p->m_referenceCount = 1;
166 m_p->m_referenceCount++;
171 if (m_p && --m_p->m_referenceCount == 0)
177 if (m_p && --m_p->m_referenceCount == 0)
179 if (r.m_referenceCount == 0)
182 m_p->m_referenceCount = 1;
186 m_p =
const_cast<T *
>(&r);
187 m_p->m_referenceCount++;
193 if (m_p && m_p->m_referenceCount > 1)
195 T *temp = m_p->clone();
196 m_p->m_referenceCount--;
198 m_p->m_referenceCount = 1;
207 if (m_p && --m_p->m_referenceCount == 0)
211 m_p->m_referenceCount++;
227 : m_size(size), m_ptr(new
member_ptr<T>[size]) {}
229 {
delete [] this->m_ptr;}
236 size_t size()
const {
return this->m_size;}
237 void resize(
size_t newSize)
240 for (
size_t i=0; i<this->m_size && i<newSize; i++)
241 newPtr[i].reset(this->m_ptr[i].release());
242 delete [] this->m_ptr;
243 this->m_size = newSize;
244 this->m_ptr = newPtr;
A pointer which can be copied and cloned.
Reference counted pointer.
Pointer that overloads operator ->
Manages resources for a single object.
Manages resources for an array of objects.
vector_member_ptrs(size_t size=0)
Construct an array of T.
Library configuration file.
Crypto++ library namespace.
#define CRYPTOPP_ASSERT(exp)
Debugging and diagnostic assertion.