Hacker News new | ask | show | jobs
by sreque 5788 days ago
Speed increases like those explained in http://www.tilander.org/aurora/2007/12/comparing-stdsort-and..., which compares qsort to std::sort.

Because templates are basically automated code copy-paste, the compiler can more easily inline at compile-time. Unfortunately, it also translates to lots more compiled code, which means slower compile times and fatter binaries. Still, writing something like the STL library in C with the same performance characteristics would be much more difficult, if not impossible.

I'm not a C++ expert, but that's my understanding of things, at least.

1 comments

If you are worried about the performance hit caused by function calling through a function pointer you might want to give a look at http://sglib.sourceforge.net/.