Merge pull request #640 from cfyzium/master

Fix non-rvalue Json::Value assignment operator (should copy, not move)
This commit is contained in:
Christopher Dunn 2017-08-01 01:22:41 -05:00 committed by GitHub
commit 7354da8077
2 changed files with 2 additions and 13 deletions

View File

@ -327,10 +327,7 @@ Json::Value obj_value(Json::objectValue); // {}
/// Deep copy, then swap(other).
/// \note Over-write existing comments. To preserve comments, use #swapPayload().
Value& operator=(const Value& other);
#if JSON_HAS_RVALUE_REFERENCES
Value& operator=(Value&& other);
#endif
Value& operator=(Value other);
/// Swap everything.
void swap(Value& other);

View File

@ -518,18 +518,10 @@ Value::~Value() {
value_.uint_ = 0;
}
Value& Value::operator=(const Value& other) {
swap(const_cast<Value&>(other));
return *this;
}
#if JSON_HAS_RVALUE_REFERENCES
Value& Value::operator=(Value&& other) {
initBasic(nullValue);
Value& Value::operator=(Value other) {
swap(other);
return *this;
}
#endif
void Value::swapPayload(Value& other) {
ValueType temp = type_;