2

I have read that we should make sure that there are no users of moved-from object before moving it. I want to know why is that so ? Is the moved-from object destroyed after std::move() is called ? if not, What happens to the moved-from object after std::move() is called ?

3 Answers3

2

It depends on how the result of std::move() is used. move itself does not do anything to the object.

kraskevich
  • 17,989
  • 3
  • 30
  • 44
0

The object is not destroyed, but it's in a state where the only thing still possible is to destroy it.

MSalters
  • 167,472
  • 9
  • 150
  • 334
0

It has to be in a state that is safe to destruct, but, AFAIK, it does not have to be usable for anything else.

ravi
  • 10,736
  • 1
  • 14
  • 33