4 ms·
> qsort might be general in the element type, but not in the container type. That is a clear advantage of C++. > Also without LTO it will be very expensive as
by pg314 9y ago
> qsort might be general in the element type, but not in the container type.
That is a clear advantage of C++.
> Also without LTO it will be very expensive as it cannot inline the compare function call.
Templates force you to expose the implementation in a header file. In C you can choose. If you move the qsort implementation in a header file, the compiler should not have any trouble inlining it.
Inlining is not always a win, though (slower compiles, bigger code, more cache misses).
- AstralStorm 9y agoModules are supposed to fix this issue in some upcoming version of C++ standard.
- pg314 9y agoThat has been the case for the last 10 years. A module system for C++ is long overdue.