Commit f05edc92 authored by Milo Yip's avatar Milo Yip Committed by GitHub

Merge pull request #1034 from bluehero/master

Allow Swap with ValueType
parents d6305514 f9004b90
......@@ -2183,6 +2183,10 @@ public:
return *this;
}
// Allow Swap with ValueType.
// Refer to Effective C++ 3rd Edition/Item 33: Avoid hiding inherited names.
using ValueType::Swap;
//! free-standing swap function helper
/*!
Helper function to enable support for common swap implementation pattern based on \c std::swap:
......
......@@ -300,7 +300,14 @@ TEST(Document, Swap) {
o.SetObject().AddMember("a", 1, a);
// Swap between Document and Value
// d1.Swap(o); // doesn't compile
d1.Swap(o);
EXPECT_TRUE(d1.IsObject());
EXPECT_TRUE(o.IsArray());
d1.Swap(o);
EXPECT_TRUE(d1.IsArray());
EXPECT_TRUE(o.IsObject());
o.Swap(d1);
EXPECT_TRUE(d1.IsObject());
EXPECT_TRUE(o.IsArray());
......
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