Rogue Wave banner
Previous fileTop of DocumentContentsIndexNext file

RWTOnlyPointer<Body>


RWTOnlyPointer<Body> RWTPointer<Body>

Data Type and Member Function Indexes
(exclusive of constructors and destructors)

Data Types

Member Functions

Package

Smart Pointer

Header File

#include <rw/pointer/RWTOnlyPointer.h>

Description

RWTOnlyPointer<Body> is an abstraction that simplifies the use of pointers referring to objects (that is, bodies) on the heap. It doesn't do reference counting on the body; rather, it is based on the idea of strict ownership semantics. Strict ownership means that if the assignment operator or the copy constructor is called, then the right-hand instance is invalidated (its body pointer is set to rwnil), and the left-hand instance assumes responsibility for deleting the body.

This class is useful for ensuring the recovery of dynamically allocated memory, specially in the presence of exceptions. This class provides functionality equivalent to that provided by the Standard C++ Library auto_ptr<> class.

Example

Public Constructors

RWTOnlyPointer(Body* bodyP=rwnil);
RWTOnlyPointer(RWStaticCtor);
RWTOnlyPointer(RWTOnlyPointer<Body>& second);

Public Destructor

~RWTOnlyPointer(void);

Public Typedef

typedef Body BodyType;  

Public Member Operators

RWTOnlyPointer<Body>&
operator=(Body* ptr);
RWTOnlyPointer<Body>&
operator=(RWTOnlyPointer<Body>& second);
operator Body*(void);
Body&
operator*(void) const;
Body*
operator->(void) const;  

Protected Member Functions

Body*
orphan(void);
void
transfer(Body* bodyP=rwnil);


Previous fileTop of DocumentContentsIndexNext file

©Copyright 2000, Rogue Wave Software, Inc.
Contact Rogue Wave about documentation or support issues.