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 ?

Ayush Chaurasia
  • 165
  • 1
  • 8

3 Answers3

2

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

kraskevich
  • 18,368
  • 4
  • 33
  • 45
0

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

MSalters
  • 173,980
  • 10
  • 155
  • 350
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,994
  • 1
  • 18
  • 36