Rogue Wave banner
Previous fileTop of DocumentContentsIndex pageNext file
Threads Module Reference Guide
Rogue Wave web site:  Home Page  |  Main Documentation Page

RWTOnlyPointer<Body>

Module:  Threads   Package:  Smart Pointer


RWTOnlyPointer<Body> RWTPointer<Body>

Local Index

Members

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 module's std::auto_ptr<> class.

Example

Public Typedef

typedef Body BodyType;  

Public Constructors

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

Public Destructor

~RWTOnlyPointer();

Public Member Operators

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

Protected Member Functions

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


Previous fileTop of DocumentContentsIndex pageNext file

© Copyright Rogue Wave Software, Inc. All Rights Reserved.
Rogue Wave and SourcePro are registered trademarks of Rogue Wave Software, Inc. in the United States and other countries. All other trademarks are the property of their respective owners.
Contact Rogue Wave about documentation or support issues.