It's not only types that have invariants. Whenever you write a loop or similar multi-step algorithm, you are thinking in terms of invariants. And not all invariants will be protected behind a class, nor would it be reasonable in general to do so.
There's nothing you can really do to protect your program against injection of random garbage data at uncontrolled points due to a moved-from object being accessed.
View all comments
Show parent comment
5
u/wyrn Aug 14 '26
It's not only types that have invariants. Whenever you write a loop or similar multi-step algorithm, you are thinking in terms of invariants. And not all invariants will be protected behind a class, nor would it be reasonable in general to do so.
There's nothing you can really do to protect your program against injection of random garbage data at uncontrolled points due to a moved-from object being accessed.