//
// SuperSmartPointer.h
//
// From Chapter 25 of Professional C++
// by Nicholas A. Solter and Scott J. Kleper
// (Wrox, 2005)
//
#include <map>
#include <iostream>

template <typename T>
class SuperSmartPointer
{
 public:
  explicit SuperSmartPointer(T* inPtr);
  ~SuperSmartPointer();

  SuperSmartPointer(const SuperSmartPointer<T>& src);
  SuperSmartPointer<T>& operator=(const SuperSmartPointer<T>& rhs);

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

  operator void*() const { return mPtr; }

 protected:
  T* mPtr;
  static std::map<T*, int> sRefCountMap;

  void finalizePointer();
  void initPointer(T* inPtr);
};

#include "SuperSmartPointer_in.h"

