template <class T> class PP_CpPtr

A Smart Pointer for Intrinsic or User-Defined Types for ParmParse

Inheritance:

PP_CpPtr


public members:

PP_CpPtr ()
PP_CpPtr (T* rhs)
~PP_CpPtr ()
PP_CpPtr (const PP_CpPtr <T>& rhs)
PP_CpPtr <T>& operator= (T* rhs)
PP_CpPtr <T>& operator= (const PP_CpPtr <T>& rhs)
T& operator* () const
bool isNull () const
T* release ()
bool operator== (const PP_CpPtr <T>& rhs) const
bool operator!= (const PP_CpPtr <T>& rhs) const

Documentation

The template class PP_CpPtr<T> provides a simple wrapper around a pointer to type T (T*) that builds a copy of the pointed-to object when copied from one PP_CpPtr<T> to another. This is in contrast to a reference-counted pointer class that would maintain one pointed-to object with a reference count indicating the number of references. Hence we call this a "copied" smart pointer class. It is intended for use with any type type T, including the intrinsic types. This class does not supply an operator->(), as such an operator on intrinsic types has only recently become a part of the C++ language, and many compilers do not yet implement it.

This is a convenience class for ParmParse and will not be in any way supported by anyone at ANAG.

PP_CpPtr ()
The default constructor. The wrapped pointer is null.

PP_CpPtr (T* rhs)
Construct a PP_CpPtr<T> setting the wrapped pointer to rhs.

~PP_CpPtr ()
The destructor. Deletes the wrapped pointer.

PP_CpPtr (const PP_CpPtr <T>& rhs)
The copy constructor. If the pointer wrapped by rhs is null, the wrapped pointer is null here as well. Otherwise, the contained pointer here is set to a new'd copy of that wrapped by rhs, with the two pointed-to values being identical. This assumes that type T has a well-defined and accessible copy constructor. T must also be a concrete type, not a abstract type.

PP_CpPtr <T>& operator= (T* rhs)
Sets the wrapped pointer to rhs. Deletes the previously wrapped pointer.

PP_CpPtr <T>& operator= (const PP_CpPtr <T>& rhs)
The copy assignment operator. If the pointer wrapped by rhs is null, the wrapped pointer is null here as well. Otherwise, the contained pointer here is set to a new'd copy of that wrapped by rhs, with the two pointed-to values being identical. This assumes that type T has a well-defined and accessible copy constructor. T must also be a concrete type, not a abstract type.

T& operator* () const
Returns a reference to the value pointed to by the wrapped pointer; i.e. dereferencing this PP_CpPtr<T>, returns the dereferenced wrapped pointer. It is an error if the wrapped pointer is null.

bool isNull () const
Returns true if the wrapped pointer null.

T* release ()
Sets the wrapped pointer to null and returns the previous value.

bool operator== (const PP_CpPtr <T>& rhs) const
Are the two pointers (not the values to which they point) equal?

bool operator!= (const PP_CpPtr <T>& rhs) const
Are the two pointers not equal?


direct child classes: PP_CpClassPtr

alphabetic index hierarchy of classes


Chombo

Copyright Notice

This software is copyright (C) by the Lawrence Berkeley National Laboratory. Permission is granted to reproduce this software for non-commercial purposes provided that this notice is left intact.

It is acknowledged that the U.S. Government has rights to this software under Contract DE-AC03-765F00098 between the U.S. Department of Energy and the University of California.

This software is provided as a professional and academic contribution for joint exchange. Thus it is experimental, is provided ``as is'', with no warranties of any kind whatsoever, no support, no promise of updates, or printed documentation. By using this software, you acknowledge that the Lawrence Berkeley National Laboratory and Regents of the University of California shall have no liability with respect to the infringement of other copyrights by any part of this software.