C++库研究笔记——使用assert还是exception?
2013-09-29 23:16
246 查看
design
by contract tests by assert or by exception?
今天也在考虑这个问题,google了下,投票最多的是:The rule of thumb is that you should use assertions when you are trying to catch your own errors, and exceptions when trying to catch other people's
errors. In other words, you should use exceptions to check the preconditions for the public API functions, and whenever you get any data that are external to your system. You should use asserts for the functions or data that are internal to your system.
总结很精辟。
另一个是:
Exception vs Assert? [duplicate]
相关文章推荐
- C++库研究笔记——使用函数模板还是类模板?+ 一个类型重复问题的两种解决方法
- C++库研究笔记——Linux下是否需要使用memory pool?
- C/C++ assert使用
- C++ 笔记 关于多态的跟java不一样的使用方法
- C++ 矩阵计算库 Eigen 使用笔记(一)
- C++笔记(10)C++箴言:谨慎使用多继承
- C++/GDI+ 学习笔记(一)——安装、配置&使用
- C++PrimerPlus第十一章学习笔记——使用类
- msgpack[C++]使用笔记 和 msgpack/cPickle性能对比
- C++学习笔记7,const关键字的使用(一)。
- C++学习笔记(五)opencv在win下的使用 —参考浅墨opencv3编程入门
- c++ stl iostream 使用笔记一
- C++库研究笔记—— [真正正确?]多维数组动态分配正确方式?(之一)
- C++学习笔记,关于一个文件中的全局变量在其他文件中的使用
- C++异常对象传递的时候,使用普通对象还是指针还是引用(使用引用)
- C++ 实现多语言程序开发研究与Xtreme ToolkitPro的使用(一)
- 使用C++还是QML(QML容易使用和维护,效果好)
- 使用c++开发学习笔记
- C++学习笔记之1:使用相同形式的new和delete
- 【C/C++】C++库研究笔记——函数名的宏定义