7 #ifndef CRYPTOPP_SMARTPTR_H 8 #define CRYPTOPP_SMARTPTR_H 27 *((
volatile T**)&m_p) = NULL;
52 const T*
get()
const {
return m_p; }
58 *((
volatile T**)&
m_p) = NULL;
121 T *old_p = this->
m_p;
122 this->
m_p = rhs.
m_p ? rhs.
m_p->Clone() : NULL;
149 const T*
get()
const {
return m_p; }
152 void attach(
const T &p);
164 m_p->m_referenceCount = 1;
171 m_p->m_referenceCount++;
176 if (
m_p && --
m_p->m_referenceCount == 0)
182 if (
m_p && --
m_p->m_referenceCount == 0)
184 if (r.m_referenceCount == 0)
187 m_p->m_referenceCount = 1;
191 m_p =
const_cast<T *
>(&r);
192 m_p->m_referenceCount++;
198 if (
m_p &&
m_p->m_referenceCount > 1)
200 T *temp =
m_p->clone();
201 m_p->m_referenceCount--;
203 m_p->m_referenceCount = 1;
212 if (
m_p && --
m_p->m_referenceCount == 0)
216 m_p->m_referenceCount++;
236 : m_size(
size), m_ptr(new
T[m_size]) {}
241 {
CRYPTOPP_ASSERT(m_size && index<this->m_size);
return this->m_ptr[index];}
243 {
CRYPTOPP_ASSERT(m_size && index<this->m_size);
return this->m_ptr[index];}
245 size_t size()
const {
return this->m_size;}
248 T *newPtr =
new T[newSize];
249 for (
size_t i=0; i<this->m_size && i<newSize; i++)
250 newPtr[i] = m_ptr[i];
251 delete [] this->m_ptr;
252 this->m_size = newSize;
253 this->m_ptr = newPtr;
260 operator const void *()
const 265 operator const T *()
const 293 {
delete [] this->m_ptr;}
300 size_t size()
const {
return this->m_size;}
304 for (
size_t i=0; i<this->m_size && i<newSize; i++)
305 newPtr[i].reset(this->m_ptr[i].release());
306 delete [] this->m_ptr;
307 this->m_size = newSize;
308 this->m_ptr = newPtr;
const T & operator*() const
const T & operator[](size_t index) const
#define NAMESPACE_BEGIN(x)
Manages resources for an array of objects.
clonable_ptr(const T &obj)
Library configuration file.
value_ptr< T > & operator=(const value_ptr< T > &rhs)
void resize(size_t newSize)
void resize(size_t newSize)
vector_ptr(size_t size=0)
Construct an arry of T.
Pointer that overloads operator ->
Reference counted pointer.
Manages resources for a single object.
A pointer which can be copied and cloned.
Manages resources for an array of objects.
member_ptr< T > & operator[](size_t index)
const T & operator*() const
const member_ptr< T > & operator[](size_t index) const
#define CRYPTOPP_ASSERT(exp)
vector_member_ptrs(size_t size=0)
Construct an arry of T.
void operator=(const member_ptr< T > &rhs)
const T * operator->() const
uint8_t const size_t const size
counted_ptr< T > & operator=(const counted_ptr< T > &rhs)
const T * operator->() const
clonable_ptr(const clonable_ptr< T > &rhs)
bool operator==(const value_ptr< T > &rhs)
T & operator[](size_t index)
value_ptr(const value_ptr< T > &rhs)
clonable_ptr< T > & operator=(const clonable_ptr< T > &rhs)