From 58b741ac4b2c60f3e96a0bf9d76939bef207747c Mon Sep 17 00:00:00 2001 From: "Philipp A. Hartmann" Date: Wed, 9 Jul 2014 11:25:55 +0200 Subject: [PATCH] tutorial.md: document GenericValue::Move() --- doc/tutorial.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/doc/tutorial.md b/doc/tutorial.md index f35c4d3..cc858f8 100644 --- a/doc/tutorial.md +++ b/doc/tutorial.md @@ -313,6 +313,17 @@ Value o(kObjectType); This is called move assignment operator in C++11. As RapidJSON supports C++03, it adopts move semantics using assignment operator, and all other modifying function like `AddMember()`, `PushBack()`. +### Move semantics and temporary values {#TemporaryValues} + +Sometimes, it is convenient to construct a Value in place, before passing it to one of the "moving" functions, like `PushBack()` or `AddMember()`. As temporary objects can't be converted to proper Value references, the convenience function `Move()` is available: + +~~~~~~~~~~cpp +Value a(kArrayType); +// a.PushBack(Value(42)); // will not compile +a.PushBack(Value().SetInt(42)); // fluent API +a.PushBack(Value(42).Move()); // same as above +~~~~~~~~~~ + ## Create String {#CreateString} RapidJSON provide two strategies for storing string.