template class CCL::SharedPtr

Smart pointer class managing a reference count.

#include <smartptr.h>

template <class T>
class SharedPtr
{
public:
    // construction

    SharedPtr (T* ptr = nullptr);
    SharedPtr (const SharedPtr& other);

    template  <class P>
    SharedPtr (const SharedPtr <P>& other);

    template  <class P>
    SharedPtr (const AutoPtr <P>& other);

    template  <class P>
    SharedPtr (const UnknownPtr <P>& other);

    // methods

    bool isValid () const;
    SharedPtr& release ();
    T* detach ();
    void** as_ppv ();
    T* as_plain () const;
    SharedPtr& assign (T* ptr);
    SharedPtr& operator = (T* ptr);
    SharedPtr& operator = (const SharedPtr& other);

    template  <class P>
    SharedPtr& operator = (const SharedPtr <P>& other);

    template  <class P>
    SharedPtr& operator = (const AutoPtr <P>& other);

    template  <class P>
    SharedPtr& operator = (const UnknownPtr <P>& other);

    T* operator -> () const;
    operator T* () const;
    operator T*& ();

    template  <class P>
    SharedPtr <T>& operator = (const SharedPtr <P>& other);

    template  <class P>
    SharedPtr <T>& operator = (const AutoPtr <P>& other);

    template  <class P>
    SharedPtr <T>& operator = (const UnknownPtr <P>& other);
};