I have found code below in "The C++ programming language, 4th edition", chapter 17.5.1.3
struct S2 {
shared_ptr<int> p;
};
S2 x {new int{0}};
void f()
{
S2 y {x}; // ‘‘copy’’ x
∗y.p = 1; // change y, affects x
∗x.p = 2; // change x; affects y
y.p.reset(new int{3}); // change y; affects x
∗x.p = 4; // change x; affects y
}
I don't understand the last comment, indeed y.p should point to a new memory address after the reset() call, and so
∗x.p = 4;
should let y.p unchanged, isn't it?
Thanks