News for hackers. Stuff that matters.
Re:Mapping Strings in C++ by lederhosen on Wednesday April 12, 2017 @07:01PM (#14102558)
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.
Re:Mapping Strings in C++ by pg314 on Thursday April 13, 2017 @06:15AM (#14105578)
> 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).

Re:Mapping Strings in C++ by AstralStorm on Thursday April 13, 2017 @07:32AM (#14105913)
Modules are supposed to fix this issue in some upcoming version of C++ standard.
Re:Mapping Strings in C++ by pg314 on Thursday April 13, 2017 @02:07PM (#14109445)
That has been the case for the last 10 years. A module system for C++ is long overdue.