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
diff options
context:
space:
mode:
authorPhilipp A. Hartmann <pah@qo.cx>2014-08-31 14:25:00 +0400
committerPhilipp A. Hartmann <pah@qo.cx>2014-08-31 14:25:00 +0400
commit1beec85453448a7186a01a1bb16848d90afe6908 (patch)
tree0b4cb356ee821ebd4c1c943021f3e725d9398913 /include/rapidjson
parentab8416e1e688302d0b77b2d7f419d68b5c6b0164 (diff)
GenericValue: add move constructor/move assignment
When C++11 is enabled, several algorithms will fail, if GenericValue is neither copyable, nor movable. Cherry-picked from 8005b55.
Diffstat (limited to 'include/rapidjson')
-rw-r--r--include/rapidjson/document.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/include/rapidjson/document.h b/include/rapidjson/document.h
index 92c73161..044a8fd0 100644
--- a/include/rapidjson/document.h
+++ b/include/rapidjson/document.h
@@ -416,6 +416,13 @@ public:
//! Default constructor creates a null value.
GenericValue() : data_(), flags_(kNullFlag) {}
+#ifdef RAPIDJSON_CXX11
+ //! Move constructor in C++11
+ GenericValue(GenericValue&& rhs) : data_(rhs.data_), flags_(rhs.flags_) {
+ rhs.flags_ = kNullFlag; // give up contents
+ }
+#endif
+
private:
//! Copy constructor is not permitted.
GenericValue(const GenericValue& rhs);
@@ -567,6 +574,13 @@ public:
return *this;
}
+#ifdef RAPIDJSON_CXX11
+ //! Move assignment in C++11
+ GenericValue& operator=(GenericValue&& rhs) {
+ return *this = rhs.Move();
+ }
+#endif
+
//! Assignment of constant string reference (no copy)
/*! \param str Constant string reference to be assigned
\note This overload is needed to avoid clashes with the generic primitive type assignment overload below.