title: RapidJSON: How to move one Document to another?
body: <p>I'm trying to pass a Document as a parameter (in this case to a C++ Class C'tor, but doens't really matter), and move it, so the orig Document will become Null, and the class member will hold the document.</p>
  
  <p>Example:</p>
  
  <pre><code>class A
  {
      rapidjson::Document m_payload;
  
      A(rapidjson::Document&amp; payload)
      {
          m_payload = payload; // DOESN'T WORK ('operator =' is a private member of 'rapidjson::GenericDocument&lt;...&gt;')
      }
  };
  </code></pre>
  
  <p>I know that if it would have been a Value, the operator= would have worked, but can't get it to work with Document.</p>
  
  <p>Workarounds I found so far:</p>
  
  <ol>
  <li><p>m_payload.Swap(payload); // This works specifically here, but not what I wanted.</p></li>
  <li><p>m_payload = std::move(payload); // I prefer not to use C++11 operations.</p></li>
  </ol>
  
  <p>Obviously I prefer to move and not copy considering performance.</p>