|
Boost : |
From: Ivan Matek (libbooze_at_[hidden])
Date: 2024-12-06 18:48:51
On Fri, Dec 6, 2024 at 7:19â¯PM Vinnie Falco <vinnie.falco_at_[hidden]> wrote:
>
>> How?
>
> maybe we are not talking about same situation, but this is what I meant,
godbolt <https://godbolt.org/z/K8xEjEoMK> link
[image: image.png]
Compiler will generate "specialized" functions for each different size of
span with non dynamic extent. Here you can see how he implemented summation
for 3 and 4 integers in different ways.
This is great for performance and makes checking easier since as Peter
explained compiler knows more, but it creates larger binaries(generally
speaking, I know compilers are smart, can inline, for 2 instantiations does
not really matter, etc).
Function taking dynamic span or runtime specified n will probably be slower
because it does normal loop, but there is only one copy of it in resulting
assembly.
There is a real life example of this here in fmt. note link gives
certificate error and I did not manage to find another link
https://vitaut.net/posts/2020/reducing-library-size/
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk