Listing 2


// synopsis of template class shared_ptr

template<class Ty> class shared_ptr {
public:
  typedef Ty element_type;

  shared_ptr();
  template<class Other>
    explicit shared_ptr(Other *ptr);
  template<class Other, class D>
    shared_ptr(Other *ptr, D dtor);
  shared_ptr(const shared_ptr& sp);
  template<class Other>
    shared_ptr(const shared_ptr<Other>& sp);
  template<class Other>
    shared_ptr(const weak_ptr<Other>& wp);
  template<class Other>
    shared_ptr(const auto_ptr<Other>& ap);

  ~shared_ptr();

  shared_ptr& operator=(const shared_ptr& sp);
  template<class Other>
    shared_ptr& operator=(const shared_ptr<Other>& sp);
  template<class Other>
    shared_ptr& operator=(const auto_ptr<Other>& ap);

  void swap(shared_ptr& sp);
  void reset();
  template<class Other>
    void reset(Other *ptr);
  template<class Other, class D>
    void reset(Other *ptr, D dtor);

  Ty *get() const;
  Ty& operator*() const;
  Ty *operator->() const;
  operator boolean-type() const;

  long use_count() const;
  bool unique() const;
};