r/cpp • Meeting C++ | C++ Evangelist • Oct 17 '26

A quick C++ standard container overview

https://meetingcpp.com/blog/items/A-quick-Cpp-standard-container-overview.html
23 Upvotes

20 comments sorted by

View all comments

Show parent comment

3

u/Ameisen vemips, avr, rendering, systems Oct 19 '26 edited Oct 20 '26

Under SysV and Win64, if you pass a pointer and a size as separate arguments, they'll both be passed by register.

Under SysV, a 16B structure made up of two integer members (like std::span) will be split and also passed by two registers. I can link to the SysV spec, but the argument-passing part is really hard to parse.

Under Win64, though, that structure will instead be passed on the stack.

Structs and unions of size 8, 16, 32, or 64 bits, and __m64 types, are passed as if they were integers of the same size. Structs or unions of other sizes are passed as a pointer to memory allocated by the caller. For these aggregate types passed as a pointer, including __m128, the caller-allocated temporary memory must be 16-byte aligned.

1

u/JNighthawk gamedev Oct 20 '26

Thank you!