Do c++ templates make programs slow?

前端 未结 5 1061
独厮守ぢ
独厮守ぢ 2020-11-29 02:53

I have heard from many people that usage of templates make the code slow. Is it really true. I\'m currently building a library. There are places where if templates are not c

5条回答
  •  旧巷少年郎
    2020-11-29 03:23

    They do make object code bigger, because C++ generates code for every type you use. But I don't believe this will slow execution speed. I have no numbers to suggest that it would.

    It certainly does improve your lot in life during code development, reading and maintenance. I would not let coding urban myths discourage you from using a language feature that's clearly useful.

提交回复
热议问题