From 6a15ca64429e1ce6d2fff915ff14ce1c2a96975c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D0=BB=D0=B5=D0=BA=D1=81=D0=B0=D0=BD=D0=B4=D1=80=20?= =?UTF-8?q?=D0=9C=D0=B0=D0=BB=D0=B8=D0=BD=D0=B8=D0=BD?= Date: Mon, 31 Jul 2017 15:29:02 +0300 Subject: [PATCH] Fix non-rvalue Json::Value assignment operator (should copy, not move) --- include/json/value.h | 5 +---- src/lib_json/json_value.cpp | 10 +--------- 2 files changed, 2 insertions(+), 13 deletions(-) diff --git a/include/json/value.h b/include/json/value.h index f0570899e..2da955949 100644 --- a/include/json/value.h +++ b/include/json/value.h @@ -327,10 +327,7 @@ Json::Value obj_value(Json::objectValue); // {} /// Deep copy, then swap(other). /// \note Over-write existing comments. To preserve comments, use #swapPayload(). - Value& operator=(const Value& other); -#if JSON_HAS_RVALUE_REFERENCES - Value& operator=(Value&& other); -#endif + Value& operator=(Value other); /// Swap everything. void swap(Value& other); diff --git a/src/lib_json/json_value.cpp b/src/lib_json/json_value.cpp index 056c4750b..791176edb 100644 --- a/src/lib_json/json_value.cpp +++ b/src/lib_json/json_value.cpp @@ -518,18 +518,10 @@ Value::~Value() { value_.uint_ = 0; } -Value& Value::operator=(const Value& other) { - swap(const_cast(other)); - return *this; -} - -#if JSON_HAS_RVALUE_REFERENCES -Value& Value::operator=(Value&& other) { - initBasic(nullValue); +Value& Value::operator=(Value other) { swap(other); return *this; } -#endif void Value::swapPayload(Value& other) { ValueType temp = type_;