rutz::shared_array< T > Class Template Reference

A reference-counted smart pointer for arrays. More...

#include <rutz/arrays.h>

Collaboration diagram for rutz::shared_array< T >:
Collaboration graph
[legend]

List of all members.

Public Types

typedef T element_type
 The pointed-to type.

Public Member Functions

 shared_array (T *p=0)
 Construct with the given array pointer.
 shared_array (const shared_array &r) throw ()
 Copy constructor.
 ~shared_array ()
 Destructor.
shared_arrayoperator= (const shared_array &r)
 Assignment oeprator.
void reset (T *p=0)
 Reset to point to a new array.
T * get () const throw ()
 Get a pointer to the pointed-to array.
T & operator[] (std::size_t i) const throw ()
 Index into the pointed-to array.
long use_count () const throw ()
 Get the reference count of the shared array.
bool unique () const throw ()
 Query whether the shared array is uniquely owned (i.e. refcount == 1).
void swap (shared_array< T > &other) throw ()
 Swap pointees with another shared_array.

Detailed Description

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

A reference-counted smart pointer for arrays.

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

Definition at line 266 of file arrays.h.


Member Typedef Documentation

template<typename T>
typedef T rutz::shared_array< T >::element_type

The pointed-to type.

Definition at line 270 of file arrays.h.


Constructor & Destructor Documentation

template<typename T>
rutz::shared_array< T >::shared_array ( T *  p = 0  )  [inline, explicit]

Construct with the given array pointer.

Ownership is now unconditionally transferred to the shared_array. If the shared_array constructor causes an exception, the pointed-to array will be destroyed.

Definition at line 276 of file arrays.h.

References rutz::ix86_atomic_int::atomic_set().

Referenced by rutz::shared_array< T >::operator=(), and rutz::shared_array< T >::reset().

template<typename T>
rutz::shared_array< T >::shared_array ( const shared_array< T > &  r  )  throw () [inline]

Copy constructor.

Definition at line 283 of file arrays.h.

References rutz::ix86_atomic_int::atomic_incr().

template<typename T>
rutz::shared_array< T >::~shared_array (  )  [inline]

Destructor.

Definition at line 287 of file arrays.h.

References rutz::ix86_atomic_int::atomic_decr_test_zero().


Member Function Documentation

template<typename T>
T* rutz::shared_array< T >::get (  )  const throw () [inline]

Get a pointer to the pointed-to array.

Definition at line 312 of file arrays.h.

Referenced by rutz::operator!=(), and rutz::operator==().

template<typename T>
shared_array& rutz::shared_array< T >::operator= ( const shared_array< T > &  r  )  [inline]

Assignment oeprator.

Definition at line 297 of file arrays.h.

References rutz::shared_array< T >::shared_array().

template<typename T>
T& rutz::shared_array< T >::operator[] ( std::size_t  i  )  const throw () [inline]

Index into the pointed-to array.

Definition at line 315 of file arrays.h.

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

Reset to point to a new array.

Definition at line 305 of file arrays.h.

References rutz::shared_array< T >::shared_array().

template<typename T>
void rutz::shared_array< T >::swap ( shared_array< T > &  other  )  throw () [inline]

Swap pointees with another shared_array.

Definition at line 324 of file arrays.h.

template<typename T>
bool rutz::shared_array< T >::unique (  )  const throw () [inline]

Query whether the shared array is uniquely owned (i.e. refcount == 1).

Definition at line 321 of file arrays.h.

References rutz::shared_array< T >::use_count().

template<typename T>
long rutz::shared_array< T >::use_count (  )  const throw () [inline]

Get the reference count of the shared array.

Definition at line 318 of file arrays.h.

References rutz::ix86_atomic_int::atomic_get().

Referenced by rutz::shared_array< T >::unique().


The documentation for this class was generated from the following file:
Generated on Sun May 8 08:31:12 2011 for iLab Neuromorphic Vision Toolkit by  doxygen 1.6.3