r/cpp • Meeting C++ | C++ Evangelist • Sep 24 '26

About alignment, struct layout and the cache...

https://meetingcpp.com/blog/items/About-alignment--struct-layout-and-the-cache---.html
36 Upvotes

27 comments sorted by

View all comments

Show parent comment

1

u/yuri-kilochek Sep 27 '26

You can wrap each member in an anonymous union to suppress automatic construction/destruction and construct/destruct manually in any order.

1

u/LB-- Professional+Hobbyist Sep 27 '26

That's the "bypassing normal language features like constructors and destructors" part of my comment. It works, but the ergonomics are awful, and you have to be especially careful about exceptions.