Overview
Examples
Screenshots
Comparisons
Applications
Download
Manual
Status & Roadmap
FAQ
Authors & License
Forums
Wiki
Funding Ultimate++
Search on this site











SourceForge.net Logo



Ptr and Pte

Ptr and Pte class templates provide a smart pointer system that cleared (assigned NULL) when pointed object is destructed. That makes it useful in situations where life-time of object cannot be precisely determined.

While Ptr class template provides smart pointers, Pte is the class which adds necessary functionality to pointed objects. Ptr could only point to objects of Pte-derived type. So to make a class "Ptr-able" you should add Pte as one of class bases, with the derived class as its parameter, e.g.:

struct Foo : Pte<Foo> {....

 

template <class T>  class Pte : public PteBase

class Pte

 

 

This template class implements the functionality needed in the pointed object.  

T    Type of pointed object.

Derived from PteBase

 

 

template <class T>  class Ptr : public PtrBase, private Moveable< Ptr<T> > 

class Ptr

 

 

Type specific pointer.

T    Type of pointed object. T class must be derived from Pte<T>.

Derived from PtrBase

 

Ptr()

Default constructor.

 

Ptr(T *ptr)

Constructs Ptr pointing to specified object.

ptr

C++ pointer to pointed object.

 

Ptr(const Ptrptr)

Constructs Ptr pointing to the same object as other Ptr.

ptr

Other Ptr.

 

T *operator->() const

Return value

C++ pointer to pointed object or NULL if Ptr does not point to any object.

 

T *operator~() const

Return value

C++ pointer to pointed object or NULL if Ptr does not point to any object.

 

operator T*() const

Return value

C++ pointer to pointed object or NULL if Ptr does not point to any object.

 

Ptr& operator=(T *ptr)

Assigns new pointer.

ptr

Pointer.

Return value

*this.

 

Ptr& operator=(const Ptr& ptr)

Assigns other Ptr.

ptr

Return value

 

friend bool operator==(const Ptr& a, const T *b)

friend bool operator==(const T *a, const Ptr& b)

friend bool operator==(const Ptr& a, const Ptr& b)

friend bool operator==(const Ptr& a, T *b)

friend bool operator==(T *a, const Ptr& b)

friend bool operator!=(const Ptr& a, const T *b)

friend bool operator!=(const T *a, const Ptr& b)

friend bool operator!=(const Ptr& a, const Ptr& b)

Comparison operators.

 

String ToString() const

Converts all information to string for diagnostic purposes

Return value

Text.