Merge pull request #736 from maxim-ky/master

Move the existing value to "removed" argument; removed is optional (could be nullptr)
This commit is contained in:
Christopher Dunn 2018-01-29 21:13:47 -06:00 committed by GitHub
commit 07a324fb14
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1186,7 +1186,12 @@ bool Value::removeMember(const char* key, const char* cend, Value* removed)
ObjectValues::iterator it = value_.map_->find(actualKey);
if (it == value_.map_->end())
return false;
*removed = it->second;
if (removed)
#if JSON_HAS_RVALUE_REFERENCES
*removed = std::move(it->second);
#else
*removed = it->second;
#endif
value_.map_->erase(it);
return true;
}