I'd like to have an exemple of when a move constructor and a move assignment operator need to be necessarily implemented because one cannot rely on the default implementations (that perform a memberwise move).
Asked
Active
Viewed 22 times
0
-
1Any time you have owning pointers would be one example – Ted Lyngmo Mar 14 '22 at 21:00
-
@TedLyngmo That's what `std::unique_ptr
` is for. – Goswin von Brederlow Mar 14 '22 at 21:01 -
Most standard library containers – Artyer Mar 14 '22 at 21:02
-
When you have a parent pointer in a tree. When you move the Node the parent pointer of the children needs to be changed to point to the destination too. – Goswin von Brederlow Mar 14 '22 at 21:02