+ 1
when should i use " move constructor"?
2 Respostas
+ 1
You would use a move constructor when the object you are moving from will not be reused and so you can assume that it can hold invalid data which can lead to great performance gains.
Something like a vector is much faster to move from as you can just assign a pointer while a copy would entail a complete copy of the array contents.
A move constructor is inherently an optimization. I suggest a read on all the different kinds of references, it's quite interesting.
+ 1
thank you, Alexandre , but I just want mention this out , a move constructor does shallow copy and that's all, simple and funny
funny because we always running away from unsafe data !!
love ya Stroustrup :||||||||||