Should/shouldn't stuff assumes you know more about the code than you actually do. |
Things I know:
*this will have it's destructor invoked when erase is called.
The code resides in a member function of *this.
If the code resides in the destructor, the destructor will be called recursively.
If the code resides in a member function, the object will cease to exist before the member function is exited. Depending on what happens in the function, all may be well. At least, until the code changes.
One invariant that all types should have is that they exist before and after the invocation of a member function that is not a constructor or destructor. It's bad design. It shouldn't be done.
This reminds me of casting a null pointer to class type to invoke a member function that one knows doesn't access any class members. It'll probably work (until the code changes,) but it shouldn't be done.
Edit: Another thought occurs to me. It's quite possible that the destructor isn't called for this object. The next object up the line may be std::move'd to this one, and that'll make for more subtle bugs whenever they decide to show up.