1

I have the following code:

rapidjson::Document response;
// parse some json string into response
std::vector<rapidjson::Document> elements;
elements.reserve(response["array"].Size());
for (auto&& array_element : response["array"].GetArray()) {
  rapidjson::Document d;
  rapidjson::Value temp(array_element.Move(), d.GetAllocator());
  temp.Swap(d);
  elements.emplace_back(std::move(d));
}

Here each of the array elements is copied to the vector as I learned by measuring the performance, but I want them to be moved. Is it possible to do (documents have different allocators)? I searched for the answer in the rapidjson tutorial and in the rapidjson unittests, but couldn't find the answer.

Thank you in advance!

0 Answers0