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.


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::mutex_atomic_int::atomic_set().

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


The documentation for this class was generated from the following file:

The software described here is Copyright (c) 1998-2005, Rob Peters.
This page was generated Wed Dec 3 06:56:31 2008 by Doxygen version 1.5.5.