Generated on: Thu Mar 29 07:46:58 PDT 2012 for custom file set
// doxy/ or-tools/ src/ base/

operations_research::scoped_array< C > Class Template Reference

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

#include <scoped_ptr.h>

List of all members.

Public Types

typedef C element_type
 The element type.

Public Member Functions

 scoped_array (C *p=NULL)
 Constructor.
 ~scoped_array ()
 Destructor.
void reset (C *p=NULL)
 Reset.
C & operator[] (std::ptrdiff_t i) const
 Get one element of the current object.
C * get () const
 Get a pointer to the zeroth element of the current object.
bool operator== (C *p) const
 Comparison operators.
bool operator!= (C *p) const
void swap (scoped_array &p2)
 Swap two scoped arrays.
C * release ()
 Release an array.


Detailed Description

template<class C>
class operations_research::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.

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

Definition at line 166 of file scoped_ptr.h.


Member Typedef Documentation

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

The element type.

Definition at line 170 of file scoped_ptr.h.


Constructor & Destructor Documentation

template<class C>
operations_research::scoped_array< C >::scoped_array ( C *  p = NULL  )  [inline, explicit]

Constructor.

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

Definition at line 175 of file scoped_ptr.h.

template<class C>
operations_research::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.

Definition at line 179 of file scoped_ptr.h.


Member Function Documentation

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

Reset.

Deletes the current owned object, if any. Then takes ownership of a new object, if given. this->reset(this->get()) works.

Definition at line 187 of file scoped_ptr.h.

template<class C>
C& operations_research::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.

Definition at line 197 of file scoped_ptr.h.

template<class C>
C* operations_research::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.

Definition at line 205 of file scoped_ptr.h.

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

Comparison operators.

These return whether two scoped_array refer to the same object, not just to two different but equal objects.

Definition at line 212 of file scoped_ptr.h.

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

Definition at line 213 of file scoped_ptr.h.

template<class C>
void operations_research::scoped_array< C >::swap ( scoped_array< C > &  p2  )  [inline]

Swap two scoped arrays.

Definition at line 216 of file scoped_ptr.h.

template<class C>
C* operations_research::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.

Definition at line 227 of file scoped_ptr.h.


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