Skip to content

Commit

Permalink
modify
Browse files Browse the repository at this point in the history
  • Loading branch information
bluehero committed Aug 7, 2017
1 parent 5fb0659 commit c831675
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 22 deletions.
6 changes: 2 additions & 4 deletions include/rapidjson/document.h
Original file line number Diff line number Diff line change
Expand Up @@ -2168,9 +2168,6 @@ class GenericDocument : public GenericValue<Encoding, Allocator> {
}
#endif

// Allow assignment like a ValueType.
using ValueType::operator=;

//! Exchange the contents of this document with those of another.
/*!
\param rhs Another document.
Expand All @@ -2186,7 +2183,8 @@ class GenericDocument : public GenericValue<Encoding, Allocator> {
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
Expand Down
21 changes: 3 additions & 18 deletions test/unittest/documenttest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit c831675

Please sign in to comment.