title: template specialization of a auto_ptr<T>
body: <p>Maybe I'm overcomplicating things, but then again, I do sort of like clean interfaces.  Let's say I want a specialization of auto_ptr for an fstream - I want a default fstream for the generic case, but allow a replacement pointer? </p>
  
  <pre><code> template &lt;&gt; 
   class auto_ptr&lt;fstream&gt; {
       static fstream myfStream; 
       fstream* ptr; 
  
   public: 
       auto_ptr() { 
           // set ptr to &amp;myfStream;
       }
       reset(fstream* newPtr) {
           // free old ptr if not the static one. 
           ptr = newPtr 
       };
    } 
  </code></pre>
  
  <p>Would you consider something different or more elegant?  And how would you keep something like the above from propagating outside this particular compilation unit? </p>
  
  <p>[The actual template is a boost::scoped_ptr.] </p>
  
  <p>EDIT: </p>
  
  <p>It's a contrived example.  Ignore the fstream - it's about providing a default instance of object for an auto_ptr.  I may not want to provide a specialized instance, but would like to keep the auto_ptr semantics for this static default object. </p>
  
  <pre><code>class UserClass { 
  public:
      auto_ptr&lt;fstream&gt; ptr; 
      UserClass() {  }
  } 
  </code></pre>
  
  <p>I may not provide an dynamic object at construction time - I still want it to have a meaningful default.  Since I'm not looking at ownership-transfer semantics, it really shouldn't matter that my pointer class is pointing to a statically allocated object, no? </p>