A reference-counted smart pointer for arrays. More...
#include <rutz/arrays.h>
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_array & | operator= (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. |
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.
typedef T rutz::shared_array< T >::element_type |
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().
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().
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().
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==().
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().
T& rutz::shared_array< T >::operator[] | ( | std::size_t | i | ) | const throw () [inline] |
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().
void rutz::shared_array< T >::swap | ( | shared_array< T > & | other | ) | throw () [inline] |
Swap pointees with another shared_array.
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().
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().