ROSE  0.9.9.139
Reference counting smart pointers

Pointers that automatically delete the underlying object.

The library makes extensive use of referencing counting smart pointers. It uses the following paradigm consistently for any class that intends to be reference counted.

A simple example:

class SomeClass {
int someData_; // underscores are used for private data members
protected:
SomeClass(): someData_(0) {}
explicit SomeClass(int n): someData_(n) {}
public:
static Ptr instance() {
return Ptr(new SomeClass);
}
static Ptr instance(int n) {
return Ptr(new SomeClass(n));
}
};
SomeClass::Ptr someClass() {
return SomeClass::instance();
}
SomeClass::Ptr someClass(int n) {
return SomeClass::instance(n);
}
Collaboration diagram for Reference counting smart pointers: