modify
This commit is contained in:
parent
8ba1f84f47
commit
5fb06596a9
@ -2168,8 +2168,7 @@ public:
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Allow assignment from ValueType.
|
// Allow assignment like a ValueType.
|
||||||
// Refer to Effective C++ 3rd Edition/Item 33: Avoid hiding inherited names.
|
|
||||||
using ValueType::operator=;
|
using ValueType::operator=;
|
||||||
|
|
||||||
//! Exchange the contents of this document with those of another.
|
//! Exchange the contents of this document with those of another.
|
||||||
@ -2188,7 +2187,6 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Allow Swap from ValueType.
|
// Allow Swap from ValueType.
|
||||||
// Refer to Effective C++ 3rd Edition/Item 33: Avoid hiding inherited names.
|
|
||||||
using ValueType::Swap;
|
using ValueType::Swap;
|
||||||
|
|
||||||
//! free-standing swap function helper
|
//! free-standing swap function helper
|
||||||
|
@ -661,17 +661,25 @@ TYPED_TEST(DocumentMove, MoveAssignmentStack) {
|
|||||||
|
|
||||||
// Issue 22: Memory corruption via operator= from Document
|
// Issue 22: Memory corruption via operator= from Document
|
||||||
// Fixed by making unimplemented assignment operator private.
|
// Fixed by making unimplemented assignment operator private.
|
||||||
// Prohibit assignment from Document, But allow assignment from Value
|
// Prohibit assignment from Document.
|
||||||
|
// But allow assignment from ValueType/int/double/..., like a ValueType
|
||||||
TEST(Document, Assignment) {
|
TEST(Document, Assignment) {
|
||||||
// Document d1;
|
// Document d1;
|
||||||
// Document d2;
|
// Document d2;
|
||||||
// d1 = d2;
|
// d1 = d2;
|
||||||
|
|
||||||
Value x(1234);
|
|
||||||
Document d;
|
Document d;
|
||||||
|
|
||||||
|
Value x(1234);
|
||||||
d = x;
|
d = x;
|
||||||
EXPECT_TRUE(x.IsNull()); // move semantic
|
EXPECT_TRUE(x.IsNull()); // move semantic
|
||||||
EXPECT_EQ(1234, d.GetInt());
|
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__
|
#ifdef __clang__
|
||||||
|
Loading…
x
Reference in New Issue
Block a user