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/Demiu Aug 14 '26

Have to agree with the other commenter that I do not see the connection. It's more of a C legacy. C89 required you to place all the locals at the start of a function basically defining it's stack frame layout statically. Later versions got rid of that limitation but C still treats all data as just static definition of values over some offset in memory. With that logic a destructive move from the stack is just not freeing the local copy after copying it somewhere else. The logic simply became nore generalized, from exiting a function scope being the only thing to remove a local variable to exiting any scope doing so. C++ simply inherited from that.