
On Fri, Dec 6, 2024 at 7:19 PM Vinnie Falco
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/