Skip to content

Commit 6c4b761

Browse files
committed
partially revert "Switch to copy-and-swap idiom for operator=."
This partially reverts commit 45cd949. 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). #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 19aaddf commit 6c4b761

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

include/json/value.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ Json::Value obj_value(Json::objectValue); // {}
257257

258258
/// Deep copy, then swap(other).
259259
/// \note Over-write existing comments. To preserve comments, use #swapPayload().
260-
Value& operator=(Value other);
260+
Value &operator=(const Value &other);
261261
/// Swap everything.
262262
void swap(Value& other);
263263
/// Swap values but leave comments and source offsets in place.

src/lib_json/json_value.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -426,8 +426,9 @@ Value::~Value() {
426426
delete[] comments_;
427427
}
428428

429-
Value& Value::operator=(Value other) {
430-
swap(other);
429+
Value &Value::operator=(const Value &other) {
430+
Value temp(other);
431+
swap(temp);
431432
return *this;
432433
}
433434

0 commit comments

Comments
 (0)