CCfits 2.7

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

Public Member Functions | Static Public Member Functions
CCfits::FITSUtil::auto_array_ptr< X > Class Template Reference

A class that mimics the std:: library auto_ptr class, but works with arrays. More...

`#include <FITSUtil.h>`

List of all members.

## Public Member Functions

| auto_array_ptr (X *p=0) throw ()
| constructor. allows creation of pointer to null, can be modified by reset()
| auto_array_ptr (auto_array_ptr< X > &right) throw ()
| copy constructor
| ~auto_array_ptr ()
| destructor.
X * | get () const
| return a token for the underlying content of *this
X & | operator* () throw ()
| deference operator
void | operator= (auto_array_ptr< X > &right)
| assignment operator: transfer of ownership semantics
X & | operator[] (size_t i) throw ()
| return a reference to the ith element of the array
X | operator[] (size_t i) const throw ()
| return a copy of the ith element of the array
X * | release () throw ()
| return underlying content of *this, transferring memory ownership
X * | reset (X *p) throw ()
| change the content of the auto_array_ptr to p

## Static Public Member Functions

static void | remove (X *&x)
| utility function to delete the memory owned by x and set it to null.

## Detailed Description

### template<typename X>
class CCfits::FITSUtil::auto_array_ptr< X >

A class that mimics the std:: library auto_ptr class, but works with arrays.

This code was written by Jack Reeves and first appeared C++ Report, March 1996 edition. Although some authors think one shouldn't need such a contrivance, there seems to be a need for it when wrapping C code.

Usage: replace

float* f = new float[200];

with

FITSUtil::auto_array_ptr<float> f(new float[200]);

Then the memory will be managed correctly in the presence of exceptions, and delete will be called automatically for f when leaving scope.

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

- FITSUtil.h