3 ms·
Your point is a decade out of date. Templates are a prime mechanism for achieving efficiency in C++ code and do not produce code-bloat like those early compile
by TickleSteve 9y ago
Your point is a decade out of date.
Templates are a prime mechanism for achieving efficiency in C++ code and do not produce code-bloat like those early compilers.
http://articles.emptycrate.com/2008/05/06/nobody_understands_c_part_5_template_code_bloat.html http://articles.emptycrate.com/2008/05/06/nobody_understands...
When templates are used to remove indirection, very good efficiency results with zero-overhead, which is a major reason why C++ sort can be quicker than qsort.
(http://www.geeksforgeeks.org/c-qsort-vs-c-sort/ http://www.geeksforgeeks.org/c-qsort-vs-c-sort/)
- quotemstr 9y agoMy point is not out of date. You can use techniques like type erasure to reduce bloat, and compilers and linkers do combine identical code sequences in many cases, but the point remains that templates work by replicating code for each instantiation. If you blindly trust the toolchain to clean up for you (as your first link suggests), you're going to run into problems. Size problems are insidious because they don't show up until they're hard to fix. I'm not suggesting that you never use templates, but I am insisting that you understand what they do instead of trusting the compiler to sweep everything under the rug.