title: Introducing smart pointers into a legacy project
body: <p>I'm changing some legacy code so that is uses smart pointers.</p>
  
  <p>Our projects pre-date boost and so we have an existing intrusive smart pointer class (see below for API).</p>
  
  <p>I want to remove explicit calls to <code>delete</code> for these types, so what is the best way to find them?</p>
  
  <p>For example:</p>
  
  <pre><code>class A : public RefCount // RefCount added to manage lifetime
  {
    // ...
  };
  // typedef A * APtr;  =&gt; Previous implementation
  typedef SPtr&lt;A&gt; APtr;
  
  void deleteObjects (APtr a)
  {
    delete a;      // Want to find this (ideally with compile error)
  }
  </code></pre>
  
  <p>All types that are to be used with the smart pointer derive from a base class that keeps a reference count, and it is this class that should be responsible for deleting the object when the count reaches zero.</p>
  
  <p>I've added what I'm doing today as an <a href="https://stackoverflow.com/questions/4510312/introducing-smart-pointers-into-a-legacy-project/4510414#4510414">answer</a>, however, the approach doesn't work for calls to delete in hierarchies.  I am looking for a complete solution that catches any explicit call to delete (other than the one from the RefCount member).</p>
  
  <p>The smart pointer class has the following members:</p>
  
  <pre><code>template &lt;typename B&gt;
  class SPtr
  {
  public:
    // Ctor
    SPtr () throw ();
    SPtr (B * b) throw ();
    SPtr (const SPtr &amp; bptr) throw ();
  
    // Copy Asgn      
    SPtr &amp; operator = (B * b);
    SPtr &amp; operator = (const SPtr &amp; bptr);
  
    // Dtor
    ~SPtr () throw ();
  
  
    // Access
    bool isSet () const;
  
    B * pointer () const;
    B * operator -&gt; () const;
    B &amp; operator * () const;
    operator void const * () const;
  };
  </code></pre>