From c831675026cc2c0a7b3581d8b0e0fe4eedd8d78f Mon Sep 17 00:00:00 2001 From: bluehero Date: Mon, 7 Aug 2017 11:58:37 +0800 Subject: [PATCH] modify --- include/rapidjson/document.h | 6 ++---- test/unittest/documenttest.cpp | 21 +++------------------ 2 files changed, 5 insertions(+), 22 deletions(-) diff --git a/include/rapidjson/document.h b/include/rapidjson/document.h index 869667a..f55b7d3 100644 --- a/include/rapidjson/document.h +++ b/include/rapidjson/document.h @@ -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 diff --git a/test/unittest/documenttest.cpp b/test/unittest/documenttest.cpp index 0d08b25..5429802 100644 --- a/test/unittest/documenttest.cpp +++ b/test/unittest/documenttest.cpp @@ -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