Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/miloyip/rapidjson.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorPhilipp A. Hartmann <pah@qo.cx>2014-07-09 13:25:55 +0400
committerPhilipp A. Hartmann <pah@qo.cx>2014-07-09 13:25:55 +0400
commit58b741ac4b2c60f3e96a0bf9d76939bef207747c (patch)
treef63ffed251f03be023afcc619543f7a1f0163608 /doc
parentedf8a0aa1da966d6fc37dc79428b2863ce8538ad (diff)
tutorial.md: document GenericValue::Move()
Diffstat (limited to 'doc')
-rw-r--r--doc/tutorial.md11
1 files changed, 11 insertions, 0 deletions
diff --git a/doc/tutorial.md b/doc/tutorial.md
index f35c4d37..cc858f80 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.