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

> If you code your class such that it's possible to let it reach an invalid state, that's no one's fault but your own.

I don't know C++ so I was given the impression in the article that the person writing the class could try very hard to make it impossible to reach an invalid state, but that this work could be ignored elsewhere by making a move of this kind which would work without any special requirements on the type itself.



You can delete the move constructor and the move assignment operator from a class, making it completely impossible to move its objects (other than through pointer arithmetic). If you have really specific class invariants it's what you should be doing. OR, the move functions should leave the moved-from members in valid states according to your invariants.




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

Search: