Do c++ templates make programs slow?

前端 未结 5 1054
独厮守ぢ
独厮守ぢ 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:32

    Since template instantiation happens at compile time, there is no run-time cost to using templates (as a matter of fact templates are sometimes used to perform certain computations at compile-time to make the program run faster). Heavy use of templates can however lead to long compile times.

提交回复
热议问题