
On 19 May 2010 21:49, Gennadiy Rozental <rogeeff@gmail.com> wrote:
I do not think this is ridiculous. This is well known fact. Templates do lead to the larger code size and larger compilation time. You can hardly argue with that.
*Instantiated* templates lead to code size. Non-instantiated ones are a parsing cost, but nothing else. Compared to a runtime collection where everything is provided through some string factory interface, in the usual case of using, say, 2 hash algorithms of the dozen provided, the template code can easily be smaller.
The same time I agree that they lead to better performance in many cases. Not always. I had number of real life scenarios where excessive inlining lead to losing locality and eventually worse performance.
Excessive inlining is an optimizer issue orthogonal to template usage.