MongoDB C++ Driver  legacy-1.1.2
Public Member Functions | List of all members
mongo::OwnedPointerVector< T > Class Template Reference

An std::vector wrapper that deletes pointers within a vector on destruction. More...

#include <owned_pointer_vector.h>

Public Member Functions

 OwnedPointerVector (std::vector< T * > other)
 Takes ownership of all pointers contained in 'other'. More...
 
OwnedPointerVectoroperator= (std::vector< T * > other)
 Takes ownership of all pointers contained in 'other'. More...
 
const std::vector< T * > & vector () const
 Access the vector. More...
 
void clear ()
 Deletes all pointers in the vector, then sets its size to 0.
 
void erase (const_iterator it)
 Deletes the pointer at 'it', then erases it from the vector.
 
std::vector< T * > release ()
 Releases the entire vector to allow you to transfer ownership. More...
 
T * releaseAt (size_t i)
 Releases ownership of a single element. More...
 

Detailed Description

template<class T>
class mongo::OwnedPointerVector< T >

An std::vector wrapper that deletes pointers within a vector on destruction.

The objects referenced by the vector's pointers are 'owned' by an object of this class. NOTE that an OwnedPointerVector<T> wraps an std::vector<T*>.

Constructor & Destructor Documentation

template<class T >
mongo::OwnedPointerVector< T >::OwnedPointerVector ( std::vector< T * >  other)
inline

Takes ownership of all pointers contained in 'other'.

NOTE: argument is intentionally taken by value.

Member Function Documentation

template<class T >
OwnedPointerVector& mongo::OwnedPointerVector< T >::operator= ( std::vector< T * >  other)
inline

Takes ownership of all pointers contained in 'other'.

NOTE: argument is intentionally taken by value.

template<class T >
std::vector<T*> mongo::OwnedPointerVector< T >::release ( )
inline

Releases the entire vector to allow you to transfer ownership.

Leaves the OwnedPointerVector empty. Named after the similar method and pattern in std::auto_ptr.

template<class T >
T* mongo::OwnedPointerVector< T >::releaseAt ( size_t  i)
inline

Releases ownership of a single element.

Sets that element to NULL and does not change size().

template<class T >
const std::vector<T*>& mongo::OwnedPointerVector< T >::vector ( ) const
inline

Access the vector.


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