title: Move Constructor calling base-class Move Constructor
body: <p>I have a base class that basically wraps up attaching a class to a arbitrary windows handle (e.g, HWND, HFONT), and uses a policy class to attach/detach and destroy:</p>
  
  <pre><code>// class SmartHandle
  template&lt;typename THANDLE, class TWRAPPER, class TPOLICY&gt;
  class SmartHandle : boost::noncopyable
  {
  private:
      TPOLICY*  m_pPolicy;    // Policy
      bool m_bIsTemporary;    // Is this a temporary window?
  
      SmartHandle();  // no default ctor
      SmartHandle(const SmartHandle&lt;THANDLE, TWRAPPER, TPOLICY&gt;&amp;);    // no cctor
  protected:
      THANDLE   m_hHandle;    // Handle to the underlying window
  
      TPOLICY&amp; policy() {return(*m_pPolicy);};
  
      // ctor that attaches but is temporary
      SmartHandle(const THANDLE&amp; _handle, bool _temporary) : m_hHandle(_handle)
                                                           , m_bIsTemporary(_temporary)
      {
          m_pPolicy = new TPOLICY(reinterpret_cast&lt;TWRAPPER&amp;&gt;(*this));
          if(_handle)
              m_pPolicy-&gt;attach(_handle);
      };  // eo ctor
  
      // move ctor
      SmartHandle(SmartHandle&lt;THANDLE, TWRAPPER, TPOLICY&gt;&amp;&amp; _rhs) : m_hHandle(_rhs.m_hHandle)
                                                                        , m_bIsTemporary(_rhs.m_bIsTemporary)
      {
          m_pPolicy = new TPOLICY(reinterpret_cast&lt;TWRAPPER&amp;&gt;(*this));
          m_pPolicy-&gt;attach(m_hHandle);
          const_cast&lt;SmartHandle&amp;&gt;(_rhs).m_hHandle = NULL;
      };  // eo mtor
  
      // dtor
      virtual ~SmartHandle()
      {
          if(m_hHandle)
          {
              m_pPolicy-&gt;detach(m_hHandle);
              if(!m_bIsTemporary)
                  m_pPolicy-&gt;destroy(m_hHandle);
              m_hHandle = NULL;
          };
          delete(m_pPolicy);
          m_pPolicy = NULL;
      }; // eo dtor
  </code></pre>
  
  <p>Note that I've declared the copy constructor private (with no implementation) as I do not want the class to be copied, but a move <em>is</em> allowed.</p>
  
  <p>My <code>Window</code> class derives from this:</p>
  
  <pre><code>    class GALLOW_API Window : SmartHandle&lt;HWND, Window, detail::_hWndPolicy&gt;
      {
      friend class Application;
      private:
          static LRESULT CALLBACK wndProc(HWND _hWnd, UINT _message, WPARAM _wParam, LPARAM _lParam);
  
          // no copy/default ctor
          Window();
          Window(const Window&amp;);
      protected:
  
      public:
          static const String ClassName;
          Window(const HWND&amp; _hWnd);
          Window(const WindowCreateInfo&amp; _createInfo);
          Window(Window&amp;&amp; _rhs);
          virtual ~Window();
      };  // eo class Window
  </code></pre>
  
  <p>Once again, copy default/copy ctors.  The implementation of the move constructor is:</p>
  
  <pre><code>    Window::Window(Window&amp;&amp; _rhs) : SmartHandle(_rhs)
      {
      };  // eo mtor
  </code></pre>
  
  <p>However, during compilation I get the following error on the first line of the move constructor implementation:</p>
  
  <pre><code>1&gt;c:\\documents\visual studio 2010\projects\gallow\gallow\window.cpp(81): error C2248: 'gallow::SmartHandle&lt;THANDLE,TWRAPPER,TPOLICY&gt;::SmartHandle' : cannot access private member declared in class 'gallow::SmartHandle&lt;THANDLE,TWRAPPER,TPOLICY&gt;'
  </code></pre>
  
  <p>So, it appears as if it is trying to call the copy constructor (which I've declared private) rather than the move constructor.  Is there something simple I am missing here?</p>
  
  <p>Thanks in advance.</p>
  
  <p>EDIT: Modified mtor so it was non-const, error remains.
  EDIT2: I am using Visual C++ 2010.</p>