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.
This commit is contained in:
parent
ab8416e1e6
commit
1beec85453
@ -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.
|
||||
|
Loading…
x
Reference in New Issue
Block a user