Skip to content

Commit 2f0c2e5

Browse files
authored
C.22 Fixes a mistake in the code example not making a deep copy (#1573)
1 parent fc383d6 commit 2f0c2e5

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

CppCoreGuidelines.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4701,7 +4701,7 @@ Users will be surprised if copy/move construction and copy/move assignment do lo
47014701
};
47024702
shared_ptr<Impl> p;
47034703
public:
4704-
Silly(const Silly& a) : p{a.p} { *p = *a.p; } // deep copy
4704+
Silly(const Silly& a) : p(make_shared<Impl>()) { *p = *a.p; } // deep copy
47054705
Silly& operator=(const Silly& a) { p = a.p; } // shallow copy
47064706
// ...
47074707
};

0 commit comments

Comments
 (0)