MongoDB C++ Driver legacy-1.1.2
Loading...
Searching...
No Matches
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'.
 
OwnedPointerVectoroperator= (std::vector< T * > other)
 Takes ownership of all pointers contained in 'other'.
 
const std::vector< T * > & vector () const
 Access the vector.
 
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.
 
T * releaseAt (size_t i)
 Releases ownership of a single element.
 

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

◆ OwnedPointerVector()

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

◆ operator=()

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.

◆ release()

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.

◆ releaseAt()

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().


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