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

2

u/FckXFckMusk Sep 26 '26

How do you expect reflection will help you..

genuine question though.

3

u/imMute Sep 27 '26

You could make an attribute that you apply on a class definition to make the reflection machinery reorder the members to reduce padding to as little as possible.

Reflection and serialization are a match made in heaven.

You could do stuff like #1 but for adjusting for cachline size to reduce false sharing.

You could pack a bunch of bools into a single word to reduce space (at the cost of losing the ability to take the address of the bools).

2

u/Kullthegreat Sep 27 '26

What we have right now - custom macro/codegen/ parser/reflection registery and serialisation etf for editor support.

Now all this is supported by compilerz, it can inspect program structure which was a lot of work for example unreal engine they built whole reflection system to help designers etc.

It is great for any new engine hobbiest or commercial now anyone can build over this.

1

u/Kullthegreat Sep 27 '26

Also my fav feature is annotations which attaches compile time meta data and can be inspected from editor. Super cool stuff. I will suggest you to read whole paper and then see how industry were doing these things.

Reflection is a big big deal not just another feature dump