InDesign SDK  20.5
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
K2::shared_array< T > Class Template Reference

#include <K2SmartPtr.h>

Public Types

typedef T element_type
 
typedef object_type data_type
 

Public Member Functions

 shared_array (T *p=0)
 
 shared_array (const shared_array &r)
 
shared_arrayoperator= (const shared_array &r)
 
void reset (T *p=0)
 
T * get () const
 
T & operator[] (std::size_t i) const
 
long use_count () const
 
bool unique () const
 
void swap (shared_array< T > &other)
 
bool operator! () const
 
 operator void * () const
 

Friends

bool operator== (const Self &lhs, const T *rhs)
 
bool operator== (const T *lhs, const Self &rhs)
 
bool operator!= (const Self &lhs, const T *rhs)
 
bool operator!= (const T *lhs, const Self &rhs)
 

Detailed Description

template<typename T>
class K2::shared_array< T >

shared_array. The array pointed to is deleted when the last shared_array pointing to it is destroyed or reset.

Member Function Documentation

template<typename T>
void K2::shared_array< T >::reset (T * p = 0)
inline

Releases the currenly owned resource and aquires the new one.

Parameters
p[IN] - pointer to the new resource.
template<typename T>
void K2::shared_array< T >::swap (shared_array< T > & other)
inline

Exchanges the contents of the two smart pointers.

Parameters
other[IN] - the second smart pointer which will exchange contents with *this.
template<typename T>
bool K2::shared_array< T >::unique () const
inline

Checks if there is only one owner of this resource.

Returns
true if there is only one owner, false otherwise.
template<typename T>
long K2::shared_array< T >::use_count () const
inline

Retrieves the usage count for this resource.

Returns
the usage count.