Commit c8316750 authored by bluehero's avatar bluehero

modify

parent 5fb06596
......@@ -2168,9 +2168,6 @@ public:
}
#endif
// Allow assignment like a ValueType.
using ValueType::operator=;
//! Exchange the contents of this document with those of another.
/*!
\param rhs Another document.
......@@ -2186,7 +2183,8 @@ public:
return *this;
}
// Allow Swap from ValueType.
// Allow Swap with ValueType.
// Refer to Effective C++/Item 33: Avoid hiding inherited names.
using ValueType::Swap;
//! free-standing swap function helper
......
......@@ -659,28 +659,13 @@ TYPED_TEST(DocumentMove, MoveAssignmentStack) {
#endif // RAPIDJSON_HAS_CXX11_RVALUE_REFS
// Issue 22: Memory corruption via operator= from Document
// Issue 22: Memory corruption via operator=
// Fixed by making unimplemented assignment operator private.
// Prohibit assignment from Document.
// But allow assignment from ValueType/int/double/..., like a ValueType
TEST(Document, Assignment) {
//TEST(Document, Assignment) {
// Document d1;
// Document d2;
// d1 = d2;
Document d;
Value x(1234);
d = x;
EXPECT_TRUE(x.IsNull()); // move semantic
EXPECT_EQ(1234, d.GetInt());
d = 1;
EXPECT_EQ(1, d.GetInt());
d = 12.34;
EXPECT_NEAR(12.34, d.GetDouble(), 0.0);
}
//}
#ifdef __clang__
RAPIDJSON_DIAG_POP
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment