Skip to content

Commit add941c

Browse files
committed
Revert "Switch to copy-and-swap idiom for operator=."
This reverts commit 45cd949. Ignored ValueInternal* changes, since those did not produce symbols for Debian build. (They must not have used the INTERNAL stuff.) #78 Conflicts: include/json/value.h src/lib_json/json_internalarray.inl src/lib_json/json_internalmap.inl src/lib_json/json_value.cpp
1 parent 9c80798 commit add941c

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

Diff for: include/json/value.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ class JSON_API Value {
171171
CZString(const char* cstr, DuplicationPolicy allocate);
172172
CZString(const CZString& other);
173173
~CZString();
174-
CZString& operator=(CZString other);
174+
CZString &operator=(const CZString &other);
175175
bool operator<(const CZString& other) const;
176176
bool operator==(const CZString& other) const;
177177
ArrayIndex index() const;
@@ -238,7 +238,7 @@ Json::Value obj_value(Json::objectValue); // {}
238238
Value(const Value& other);
239239
~Value();
240240

241-
Value& operator=(Value other);
241+
Value &operator=(const Value &other);
242242
/// Swap values.
243243
/// \note Currently, comments are intentionally not swapped, for
244244
/// both logic and efficiency.

Diff for: src/lib_json/json_value.cpp

+6-4
Original file line numberDiff line numberDiff line change
@@ -188,8 +188,9 @@ void Value::CZString::swap(CZString& other) {
188188
std::swap(index_, other.index_);
189189
}
190190

191-
Value::CZString& Value::CZString::operator=(CZString other) {
192-
swap(other);
191+
Value::CZString &Value::CZString::operator=(const CZString &other) {
192+
CZString temp(other);
193+
swap(temp);
193194
return *this;
194195
}
195196

@@ -478,8 +479,9 @@ Value::~Value() {
478479
delete[] comments_;
479480
}
480481

481-
Value& Value::operator=(Value other) {
482-
swap(other);
482+
Value &Value::operator=(const Value &other) {
483+
Value temp(other);
484+
swap(temp);
483485
return *this;
484486
}
485487

0 commit comments

Comments
 (0)