What are the disadvantages of using templates?

前端 未结 11 698
生来不讨喜
生来不讨喜 2020-12-16 01:02

Some of the disadvantages would be

  1. its syntax is complex
  2. compiler generates extra code
11条回答
  •  一向
    一向 (楼主)
    2020-12-16 01:39

    Hmm, how about...

    3: They can be slow to compile

    4: They force things to be calculated at compile time rather than run time (this can also be an advantage, if you prefer fast execution speed over runtime flexibility)

    5: Older C++ compilers don't handle them, or don't handle them correctly

    6: The error messages that they generate when you don't get the code right can be nearly incomprehensible

提交回复
热议问题