From 096c81de85a2b096296143f818d3eac136eb77d0 Mon Sep 17 00:00:00 2001 From: Christopher Dunn Date: Mon, 17 Nov 2014 00:13:18 -0600 Subject: [PATCH] Revert "Switch to copy-and-swap idiom for operator=." This reverts commit 45cd9490cd261da31cef84a44d2c587be7e26e99. Ignored ValueInternal* changes, since those did not produce symbols for Debian build. (They must not have used the INTERNAL stuff.) 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 | 4 ++-- src/lib_json/json_value.cpp | 10 ++++++---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/include/json/value.h b/include/json/value.h index 62a323b..ae6f661 100644 --- a/include/json/value.h +++ b/include/json/value.h @@ -172,7 +172,7 @@ private: CZString(const char* cstr, DuplicationPolicy allocate); CZString(const CZString& other); ~CZString(); - CZString& operator=(CZString other); + CZString &operator=(const CZString &other); bool operator<(const CZString& other) const; bool operator==(const CZString& other) const; ArrayIndex index() const; @@ -241,7 +241,7 @@ Json::Value obj_value(Json::objectValue); // {} ~Value(); // Deep copy, then swap(other). - 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 f9139c7..16bfad9 100644 --- a/src/lib_json/json_value.cpp +++ b/src/lib_json/json_value.cpp @@ -192,8 +192,9 @@ void Value::CZString::swap(CZString& other) { std::swap(index_, other.index_); } -Value::CZString& Value::CZString::operator=(CZString other) { - swap(other); +Value::CZString &Value::CZString::operator=(const CZString &other) { + CZString temp(other); + swap(temp); return *this; } @@ -409,8 +410,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; }