2 ms·
I don’t even see why a macro would come to mind as a first solution when you can just use a fold.
by evincarofautumn 11y ago
I don’t even see why a macro would come to mind as a first solution when you can just use a fold.
- SamReidHughes 11y agoThat would be horribly slow.
- evincarofautumn 11y agoWould it? Inlining the fold should produce the same code, with no intermediate vector. Granted, such inlining is not guaranteed, whereas with a macro it would be.
- SamReidHughes 11y agoI don't know about compiler optimization but there's a bit more to it than inlining a fold.
- SamReidHughes 11y agoI just tried it and sometimes it avoided the vector allocation but at least once it allocated and filled the vector, and then immediately deallocated it. (It didn't reread the data back from the vector.)