g2o
Public Member Functions | Protected Attributes | Private Member Functions | List of all members
g2o::ScopedArray< T > Class Template Reference

a scoped pointer for an array, i.e., array will be deleted on leaving the scope More...

#include <scoped_pointer.h>

Public Member Functions

 ScopedArray (T *t=0)
 
 ~ScopedArray ()
 
T & operator[] (std::ptrdiff_t i) const
 
T * get () const
 return the pointer More...
 
void reset (T *p)
 
void swap (ScopedArray &b)
 

Protected Attributes

T * _pointer
 

Private Member Functions

 ScopedArray (const ScopedArray &)
 
const ScopedArrayoperator= (const ScopedArray &)
 

Detailed Description

template<typename T>
class g2o::ScopedArray< T >

a scoped pointer for an array, i.e., array will be deleted on leaving the scope

Definition at line 97 of file scoped_pointer.h.

Constructor & Destructor Documentation

template<typename T >
g2o::ScopedArray< T >::ScopedArray ( T *  t = 0)
inline

Definition at line 100 of file scoped_pointer.h.

100 : _pointer(t) {}
template<typename T >
g2o::ScopedArray< T >::~ScopedArray ( )
inline

Definition at line 102 of file scoped_pointer.h.

103  {
104  delete[] _pointer;
105  }
template<typename T >
g2o::ScopedArray< T >::ScopedArray ( const ScopedArray< T > &  )
private

Member Function Documentation

template<typename T >
T* g2o::ScopedArray< T >::get ( ) const
inline

return the pointer

Definition at line 114 of file scoped_pointer.h.

114 { return _pointer;}
template<typename T >
const ScopedArray& g2o::ScopedArray< T >::operator= ( const ScopedArray< T > &  )
private
template<typename T >
T& g2o::ScopedArray< T >::operator[] ( std::ptrdiff_t  i) const
inline

Definition at line 107 of file scoped_pointer.h.

108  {
109  assert(_pointer != 0 && i >= 0);
110  return _pointer[i];
111  }
template<typename T >
void g2o::ScopedArray< T >::reset ( T *  p)
inline

store another array pointer inside

Definition at line 119 of file scoped_pointer.h.

120  {
121  assert((p == 0 || p != _pointer) && "ScopedPointer should not reset with itself");
122  ScopedArray aux(p);
123  swap(aux);
124  }
void swap(ScopedArray &b)
template<typename T >
void g2o::ScopedArray< T >::swap ( ScopedArray< T > &  b)
inline

swap with another pointer

Definition at line 129 of file scoped_pointer.h.

References g2o::ScopedArray< T >::_pointer.

130  {
131  T* aux = b._pointer;
132  b._pointer = _pointer;
133  _pointer = aux;
134  }

Member Data Documentation

template<typename T >
T* g2o::ScopedArray< T >::_pointer
protected

Definition at line 137 of file scoped_pointer.h.

Referenced by g2o::ScopedArray< T >::swap().


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