From 74b41c1a430ed9e6b6f3c2e5c6f906f3c4520a63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20=C5=81oskot?= Date: Wed, 24 Jun 2015 17:22:48 +0200 Subject: [PATCH] Add missing allocator to uses of AddMember AddMember requires allocator, this fix keeps all uses of AddMember consistent across the whole tutorial. --- doc/tutorial.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/doc/tutorial.md b/doc/tutorial.md index 3508918..1211023 100644 --- a/doc/tutorial.md +++ b/doc/tutorial.md @@ -292,12 +292,13 @@ The simple answer is performance. For fixed size JSON types (Number, True, False For example, if normal *copy* semantics was used: ~~~~~~~~~~cpp +Document d; Value o(kObjectType); { Value contacts(kArrayType); // adding elements to contacts array. // ... - o.AddMember("contacts", contacts); // deep clone contacts (may be with lots of allocations) + o.AddMember("contacts", contacts, d.GetAllocator()); // deep clone contacts (may be with lots of allocations) // destruct contacts. } ~~~~~~~~~~ @@ -313,11 +314,12 @@ To make RapidJSON simple and fast, we chose to use *move* semantics for assignme So, with move semantics, the above example becomes: ~~~~~~~~~~cpp +Document d; Value o(kObjectType); { Value contacts(kArrayType); // adding elements to contacts array. - o.AddMember("contacts", contacts); // just memcpy() of contacts itself to the value of new member (16 bytes) + o.AddMember("contacts", contacts, d.GetAllocator()); // just memcpy() of contacts itself to the value of new member (16 bytes) // contacts became Null here. Its destruction is trivial. } ~~~~~~~~~~