Skip to content

Commit 6378c86

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.) open-source-parsers#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 7cdee78 commit 6378c86

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
@@ -172,7 +172,7 @@ class JSON_API Value {
172172
CZString(const char* cstr, DuplicationPolicy allocate);
173173
CZString(const CZString& other);
174174
~CZString();
175-
CZString& operator=(CZString other);
175+
CZString &operator=(const CZString &other);
176176
bool operator<(const CZString& other) const;
177177
bool operator==(const CZString& other) const;
178178
ArrayIndex index() const;
@@ -241,7 +241,7 @@ Json::Value obj_value(Json::objectValue); // {}
241241
~Value();
242242

243243
// Deep copy, then swap(other).
244-
Value& operator=(Value other);
244+
Value &operator=(const Value &other);
245245
/// Swap everything.
246246
void swap(Value& other);
247247
/// Swap values but leave comments and source offsets in place.

Diff for: src/lib_json/json_value.cpp

+6-4
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,9 @@ void Value::CZString::swap(CZString& other) {
192192
std::swap(index_, other.index_);
193193
}
194194

195-
Value::CZString& Value::CZString::operator=(CZString other) {
196-
swap(other);
195+
Value::CZString &Value::CZString::operator=(const CZString &other) {
196+
CZString temp(other);
197+
swap(temp);
197198
return *this;
198199
}
199200

@@ -409,8 +410,9 @@ Value::~Value() {
409410
delete[] comments_;
410411
}
411412

412-
Value& Value::operator=(Value other) {
413-
swap(other);
413+
Value &Value::operator=(const Value &other) {
414+
Value temp(other);
415+
swap(temp);
414416
return *this;
415417
}
416418

0 commit comments

Comments
 (0)