Template metaprogramming(TMP,模板元编程)可将工作由运行期移往编译期,因而得以实现早期错误侦测和更高的执行效率. TMP可被用来生成“基于政策选择组合”(based on combinations of policy choices)的客户定制代码,也可用来避免生成对某些特殊类型并不适合的代码.
Reason The float and double types are particularly ill-suited for monetary calculations because it is impossible to represent 0.1 (or any other negative power of ten) as a float or double exactly. // This will print 0.6100000000000001 System.out.prin
条款41:了解隐式接口和编译期多态 class支持显示接口和运行期多态 class的显示接口由函数的名签式构成(函数名称.参数类型.返回类型) class的多态通过virtual函数发生在运行期 template支持隐式接口和编译期多态 template的接口是隐式的,由具体的表达式决定 template的多态是通过其具现化和函数重载解析发生在编译期 //这里接口要求T必须实现operator >这个隐式接口 template<typename T> T max(T a, T b){ r
Effective C++算是看完了,但是并没有完全理解,也做不到记住所有,在此记录下55个条款及条款末的"请记住". 让自己习惯C++ 条款01:视C++为一个语言联邦 ① C ② Object-Oriented C++ ③ Template C++ ④ STL 条款02:尽量以const,enum,inline替换#define ① 对于单纯常量,最好以const对象或enums替换#define ② 对于形似函数的宏,最好改用inline函数替换#define 条款03:尽可能使
Hi guys, I am happy to tell you that I am moving to the open source world. And Java is the 1st language I have chosen for this migration. It's a nice chance to read some great books like "Effective Java 2nd Edition" and share the note for what I