Re:Fun with C++26 reflection: Keyword Arguments
by ranger_danger on Monday February 10, 2025 @09:41PM
(#43008338)
at that point why not just pass in a struct as your argument
[ Parent
| on HN ]
Re:Fun with C++26 reflection: Keyword Arguments
by jcelerier on Tuesday February 11, 2025 @12:05AM
(#43009182)
depending on the platform this may cause things to be pushed / poped on the stack instead of being passed as registers
Re:Fun with C++26 reflection: Keyword Arguments
by anitil on Monday February 10, 2025 @10:02PM
(#43008454)
I suppose it depends on your application. I worked in embedded devices where stack was limited and the compiler was .... less than reliable about how it would manage passing a large struct to your function, which is why I mentioned passing in a pointer instead
Re:Fun with C++26 reflection: Keyword Arguments
by ranger_danger on Monday February 10, 2025 @11:26PM
(#43008961)
yes a pointer to struct would be acceptable as well
Re:Fun with C++26 reflection: Keyword Arguments
by RossBencina on Tuesday February 11, 2025 @12:28AM
(#43009302)
In 1998 perhaps. It wouldn't be acceptable to today's C++ value-semantics crowd. Are you sure that you want to take the indirection penalty? or that the compiler will optimise it away?
Re:Fun with C++26 reflection: Keyword Arguments
by BodkinsOdds on Tuesday February 11, 2025 @01:47AM
(#43009745)
C++ is already so reliant on optimizing `const&` parameters that I can't imagine why you wouldn't use them if you happen to be stuck with a shitty embedded toolchain (or MSVC) that can't be relied on to pass struct parameters efficiently.
Re:Fun with C++26 reflection: Keyword Arguments
by gpderetta on Tuesday February 11, 2025 @06:33AM
(#43011629)
If stack space usage is an issue, then it means that the struct is already being passed by hidden pointer (as opposed to using a register passing calling convention). Making the pointer explicit won't have any effect on performance (but it will on semantics).