Commit 1beec854 authored by Philipp A. Hartmann's avatar Philipp A. Hartmann

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.
parent ab8416e1
...@@ -416,6 +416,13 @@ public: ...@@ -416,6 +416,13 @@ public:
//! Default constructor creates a null value. //! Default constructor creates a null value.
GenericValue() : data_(), flags_(kNullFlag) {} 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: private:
//! Copy constructor is not permitted. //! Copy constructor is not permitted.
GenericValue(const GenericValue& rhs); GenericValue(const GenericValue& rhs);
...@@ -567,6 +574,13 @@ public: ...@@ -567,6 +574,13 @@ public:
return *this; 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) //! Assignment of constant string reference (no copy)
/*! \param str Constant string reference to be assigned /*! \param str Constant string reference to be assigned
\note This overload is needed to avoid clashes with the generic primitive type assignment overload below. \note This overload is needed to avoid clashes with the generic primitive type assignment overload below.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment