title: How could one implement std::auto_ptr's copy constructor?
body: <p>Back on my crazy <a href="https://bitbucket.org/BillyONeal/pevfind/src/64bc8a6e3d87/pevFind/Win32AutoArray.hpp" rel="nofollow">AutoArray thingy</a>... (quoting important bits from there:</p>
  
  <pre><code>class AutoArray
  {
      void * buffer;
  public:
      //Creates a new empty AutoArray
      AutoArray();
      //std::auto_ptr copy semantics
      AutoArray(AutoArray&amp;); //Note it can't be const because the "other" reference
                             //is null'd on copy...
      AutoArray&amp; operator=(AutoArray);
      ~AutoArray();
      //Nothrow swap
      // Note: At the moment this method is not thread safe.
      void Swap(AutoArray&amp;);
  };
  </code></pre>
  
  <p>)</p>
  
  <p>Anyway, trying to implement the copy constructor. There's a piece of client code (not yet committed into bitbucket because it won't build) that looks like this:</p>
  
  <pre><code>AutoArray NtQuerySystemInformation(...) { ... };
  
  AutoArray systemInfoBuffer = NtQuerySystemInformation(...);
  </code></pre>
  
  <p>This fails because the copy constructor takes a non-<code>const</code> reference as an argument .... but I don't see how you could modify the copy constructor to take a <code>const</code> reference, given that the source <code>AutoArray</code> used in the assignment is modified (and therefore wouldn't be <code>const</code>). You can't modify things to use pass by value of course, because it's the copy constructor and that'd be an infinite loop!</p>
  
  <p>If I was using <code>auto_ptr</code>, this would be valid:</p>
  
  <pre><code>std::auto_ptr NtQuerySystemInformation(...) { ... };
  
  std::auto_ptr systemInfoBuffer = NtQuerySystemInformation(...);
  </code></pre>
  
  <p>How then, can a class with <code>auto_ptr</code>'s copy semantics be possible?</p>