4 ms·
qsort might be general in the element type, but not in the container type. That is, it will only work for arrays. Also without LTO it will be very expensive as
by lederhosen 10y ago
qsort might be general in the element type, but not in the container type. That is, it will only work for arrays.
Also without LTO it will be very expensive as it cannot inline the compare function call. C++ sort is just faster and more powerful.
- pg314 10y 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 10y agoModules are supposed to fix this issue in some upcoming version of C++ standard.
- pg314 10y agoThat has been the case for the last 10 years. A module system for C++ is long overdue.