3 ms·
std::sort and other templates make you pay in terms of header complexity (no circular includes for example) and compilation time. For the most part it’s a good
by CoolGuySteve 8y ago
std::sort and other templates make you pay in terms of header complexity (no circular includes for example) and compilation time.
For the most part it’s a good trade off, particularly std::sort and some of the other <algorithms>. But I’ve yet to work on a long lived low latency/high performance C++ project where some wizard coworker has not tanked the code base for purely theoretical gains that turn out to not meaningfully change the assembly or change it by an instruction or two.
Godbolt is a revelation when these situations arise, but good luck even then convincing someone who just spent 4 days writing a dispatch or whatever that it was all a waste.
I guess what I’m saying is that when it comes to template-oriented performance programming, std::sort is the exception, not the rule.
Or maybe the good templates are small and modular so their footprint is 1/10th that of a bad template such that we just don’t notice them as much.