The underlying analysis of std::move() movement semantics of std::shared_ptr
Before executing std::move():
After executing std::move():
Conclusion: a shallow copy
sizeof(std::shared_ptr) = 8 bytes
pss1: 0x0028fea8
pss2: 0x0028fea0
(the stack is inversely growing)
Observe the value of 8 bytes starting from pss1: 0x0028fea8 before std::move is
executed , and then after executing pss1: 0x0028fea8 After copying the value of the first 8 bytes to pss2: 0x0028fea0, clear the value of the first 8 bytes of pss1: 0x0028fea8.
process:
The function of std::move() is to convert an lvalue to an rvalue,
so when std::stdred_ptr<> pss2(std::move(pss1)) is executed, the move structure of std::shared_ptr<> is called Function (movement construction requires an rvalue), and the movement constructor is a shallow copy operation.