在C ++中对模板和STL的缺点 [英] Drawbacks to templates and the STL in C++

查看:128
本文介绍了在C ++中对模板和STL的缺点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用STL或模板有任何缺点。

Are there any drawbacks to using the STL or templates. Are there any situations for which they are inappropriate.

推荐答案

首先,你应该使用它们,如果他们帮助你解决你的问题。模板是C ++的一个非常重要的部分,并且已经是标准的一部分。 STL在运行时非常强大和快速,应该在所有合格的编译器上支持,但是当然有问题。

First, you should use probably use them if they help you solve your problem. Templates are a very important part of C++ and have been part of the standard for years. STL is very powerful and fast at run time and should be supported on all decent compilers, but of course there are issues.



  • STL实现的线程安全性可能适用于您的应用程序

  • 模板可以

  • 编译器通常会使用模板对代码使用不可理解的错误消息。

  • If you have a really old compiler, STL might not be completely supported.
  • The thread-safety of the STL implementation might be work for your application
  • Templates can lead to slower compile-times and possibly larger executable, especially with older compilers.
  • Compilers often produce incomprehensible error messages on code using templates.

只是举几个例子,但是不使用它们的缺点可能会更大。

just to name a few, but the drawbacks of not using them are likely to be much greater.

这篇关于在C ++中对模板和STL的缺点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆