mirror of
https://github.com/isocpp/CppCoreGuidelines.git
synced 2024-03-22 13:30:58 +08:00
C.22 Fixes a mistake in the code example not making a deep copy (#1573)
This commit is contained in:
parent
fc383d6641
commit
2f0c2e5874
|
@ -4701,7 +4701,7 @@ Users will be surprised if copy/move construction and copy/move assignment do lo
|
|||
};
|
||||
shared_ptr<Impl> p;
|
||||
public:
|
||||
Silly(const Silly& a) : p{a.p} { *p = *a.p; } // deep copy
|
||||
Silly(const Silly& a) : p(make_shared<Impl>()) { *p = *a.p; } // deep copy
|
||||
Silly& operator=(const Silly& a) { p = a.p; } // shallow copy
|
||||
// ...
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue
Block a user