Pallas Solver  0.1
C++ Global Optimization Algorithms
Public Types | Public Member Functions | List of all members
pallas::scoped_array< C > Class Template Reference

#include <scoped_ptr.h>

Public Types

typedef C element_type
 

Public Member Functions

 scoped_array (C *p=NULL)
 Constructor. More...
 
 ~scoped_array ()
 Destructor. More...
 
void reset (C *p=NULL)
 Deletes the current owned object, if any. More...
 
C & operator[] (std::ptrdiff_t i) const
 Get one element of the current object. More...
 
C * get () const
 Get a pointer to the zeroth element of the current object. More...
 
bool operator== (const C *p) const
 
bool operator!= (const C *p) const
 
void swap (scoped_array &p2)
 
C * release ()
 Release an array.]. More...
 

Detailed Description

template<class C>
class pallas::scoped_array< C >

scoped_array<C> is like scoped_ptr<C>, except that the caller must allocate with new [] and the destructor deletes objects with delete [].

As with scoped_ptr<C>, a scoped_array<C> either points to an object or is NULL. A scoped_array<C> owns the object that it points to. scoped_array<T> is thread-compatible, and once you index into it, the returned objects have only the threadsafety guarantees of T.

Size: sizeof(scoped_array<C>) == sizeof(C*)

Member Typedef Documentation

template<class C>
typedef C pallas::scoped_array< C >::element_type

The element type

Constructor & Destructor Documentation

template<class C>
pallas::scoped_array< C >::scoped_array ( C *  p = NULL)
inlineexplicit

Constructor.

Defaults to intializing with NULL. There is no way to create an uninitialized scoped_array. The input parameter must be allocated with new [].

template<class C>
pallas::scoped_array< C >::~scoped_array ( )
inline

Destructor.

If there is a C object, delete it. We don't need to test ptr_ == NULL because C++ does that for us.

Member Function Documentation

template<class C>
C* pallas::scoped_array< C >::get ( ) const
inline

Get a pointer to the zeroth element of the current object.

If there is no current object, return NULL.

Here is the caller graph for this function:

template<class C>
bool pallas::scoped_array< C >::operator!= ( const C *  p) const
inline

Returns whether a scoped_array and a raw pointer refer to different arrays.

template<class C>
bool pallas::scoped_array< C >::operator== ( const C *  p) const
inline

Returns whether a scoped_array and a raw pointer refer to the same array, not just to two different but equal arrays.

template<class C>
C& pallas::scoped_array< C >::operator[] ( std::ptrdiff_t  i) const
inline

Get one element of the current object.

Will assert() if there is no current object, or index i is negative.

template<class C>
C* pallas::scoped_array< C >::release ( )
inline

Release an array.].

The return value is the current pointer held by this object. If this object holds a NULL pointer, the return value is NULL. After this operation, this object will hold a NULL pointer, and will not own the object any more.

Here is the call graph for this function:

template<class C>
void pallas::scoped_array< C >::reset ( C *  p = NULL)
inline

Deletes the current owned object, if any.

Takes ownership of a new object, if given. this->reset(this->get()) works.

template<class C>
void pallas::scoped_array< C >::swap ( scoped_array< C > &  p2)
inline

Swap two scoped arrays.]

Here is the caller graph for this function:


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