Hacker Timesnew | past | comments | ask | show | jobs | submitlogin

Move constructors are allowed to call the moved object's destructor.

Not necessarily like the example given, but

  Object a {std::move(x)};
  x.push_back(4);
could/should segfault.


No, move constructors are never allowed to call the moved-from argument's destructor. Ever.

Sometimes the compiler calls that destructor after it has finished the move, if the thing is no longer in scope. That should not be confused with a thing happening in the constructor.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: