Merge pull request #1034 from bluehero/master
Allow Swap with ValueType
This commit is contained in:
commit
f05edc9296
@ -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());
|
||||
|
Loading…
x
Reference in New Issue
Block a user