6 ms·
Huh? Templates in C++ are pay-for-what-you-use; only those instantiations required by your code are generated. Note also the ability to extern templates added
by johnny531 15y ago
Huh? Templates in C++ are pay-for-what-you-use; only those instantiations required by your code are generated.
Note also the ability to extern templates added in C++0x, which allow you to collapse common instantiations to a single object file.
- seabee 15y agoHow do those features impact runtime performance? One example of templates affecting runtime performance is poor use of the instruction cache due to code duplication in every instantiation of a template.
- corysama 15y agoIf you are instantiating equivalent functions (sorting foo* vs sorting bar* ) then the linker will merge their binaries -no dupes there. If you are generating different functions (sorting foo vs foo* ) then you are asking for different functions -no dupes there either. If you want to keep everything down to one function, qsort() didn't disappear when they added std::sort() and it is pretty close to what a dynamic language sort would do under the hood.
- lanstein 15y agoC++0B maybe?