From 1c4f6a2d79d466bb501cb84626f269e40e60ba7c Mon Sep 17 00:00:00 2001 From: Christopher Dunn Date: Mon, 17 Nov 2014 00:13:18 -0600 Subject: [PATCH] partially revert "Switch to copy-and-swap idiom for operator=." This partially reverts commit 45cd9490cd261da31cef84a44d2c587be7e26e99. Ignored ValueInternal* changes, since those did not produce symbols for Debian build. (They must not have used the INTERNAL stuff.) Ignored CZString changes since those are private (and sizeof struct did not change). https://github.com/open-source-parsers/jsoncpp/issues/78 Conflicts: include/json/value.h src/lib_json/json_internalarray.inl src/lib_json/json_internalmap.inl src/lib_json/json_value.cpp --- include/json/value.h | 2 +- src/lib_json/json_value.cpp | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) 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; }