r/cpp • • Aug 13 '26

C++26: std::indirect

https://www.sandordargo.com/blog/2026/08/12/cpp26-indirect
164 Upvotes

157 comments sorted by

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.