(a) 可用 STL 常用的方式:
~cpp
Document doc;
// ...
{
Document newDoc;
doc.Swap(newDoc);
}
~
(b) 用预设的 allocator 类型的话,又保证分配了的内存不再被使用,可:
~cpp
doc.SetNull(); // 把根节点设为 null JSON 类型
doc.GetAllocator().Clear(); // 清空 allocator
~
doc.GetAllocator().Size() 返回已分配的大小.非常感谢~~~
在 2017-10-20 10:52:20,"Milo Yip" notifications@github.com 写道:
至少两个方法
(a) 可用 STL 常用的方式:
Document doc;
// ...
{
Document newDoc;
doc.Swap(newDoc);
}
(b) 用预设的 allocator 类型的话,又保证分配了的内存不再被使用,可:
doc.SetNull(); // 把根节点设为 null JSON 类型
doc.GetAllocator().Clear(); // 清空 allocator
用预设的 allocator 类型的话,可用 doc.GetAllocator().Size() 返回已分配的大小.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or mute the thread.
非常感谢~~~
Most helpful comment
(a) 可用 STL 常用的方式:
~cppDocument doc;
// ...
{
Document newDoc;
doc.Swap(newDoc);
}
~
(b) 用预设的 allocator 类型的话,又保证分配了的内存不再被使用,可:
~cppdoc.SetNull(); // 把根节点设为 null JSON 类型
doc.GetAllocator().Clear(); // 清空 allocator
~
doc.GetAllocator().Size()返回已分配的大小.