diff --git a/include/json/value.h b/include/json/value.h index 26bb38b..62bee43 100644 --- a/include/json/value.h +++ b/include/json/value.h @@ -283,7 +283,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 8fbce54..5b7e64a 100644 --- a/src/lib_json/json_value.cpp +++ b/src/lib_json/json_value.cpp @@ -466,8 +466,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; }