diff --git a/include/json/value.h b/include/json/value.h index b752fb8..d18b347 100644 --- a/include/json/value.h +++ b/include/json/value.h @@ -257,7 +257,7 @@ Json::Value obj_value(Json::objectValue); // {} /// Deep copy, then swap(other). /// \note Over-write existing comments. To preserve comments, use #swapPayload(). - Value& operator=(Value other); + Value &operator=(const Value &other); /// Swap everything. void swap(Value& other); /// Swap values but leave comments and source offsets in place. diff --git a/src/lib_json/json_value.cpp b/src/lib_json/json_value.cpp index 46385b9..38dadc9 100644 --- a/src/lib_json/json_value.cpp +++ b/src/lib_json/json_value.cpp @@ -421,8 +421,9 @@ Value::~Value() { delete[] comments_; } -Value& Value::operator=(Value other) { - swap(other); +Value &Value::operator=(const Value &other) { + Value temp(other); + swap(temp); return *this; }