▲ | spacechild1 5 days ago | |
> Having to make every type contain an “empty” case, just to make the language’s move semantics work, pokes an enormous hole through this idea. Nobody says that the invariants must hold after the object has been moved-from! The only thing you need to do is make sure that the destructor can run and do the right thing. > You can pinky-swear to never use the moved-from value in your own code (and linters can help here) but the possibility still exists, so it must be solved for. Letting the program crash would be a valid solution (for your own types). For me the issue with C++ move semantics is not so much that you have to add special logic to your classes, but the fact that moved-from objects can be accessed in the first place. In this respect I definitely agree that destructive moves are better. |