Perform a copy of Document object of rapidjson

后端 未结 4 593
小鲜肉
小鲜肉 2020-12-20 20:32

I\'m making a class and I want to return my class inside a method. My class has a rapidjson::Document object.

You can see the previous problems here: L

4条回答
  •  离开以前
    2020-12-20 21:01

    Use the CopyFrom method on a new Document:

    rapidjson::Document inDoc;    // source document
    rapidjson::Document outDoc;   // destination document
    outDoc.CopyFrom(inDoc, outDoc.GetAllocator());
    

    I tested this approach and changes made to the output document had no effect on the input document. Make sure the CopyFrom method is given the output document's allocator.

提交回复
热议问题