是否有任何理由不能将double作为参数类型与模板?
例如:
例如:
- template<int N>//-< Legal
- struct
- {
- };
- template<double N>//-< Illegal
- struct
- {
- };
在C 11中是否有任何更新?
解决方法
这与精度有关,浮点数无法精确表示,并且您引用相同类型的可能性取决于数字的表示方式.考虑使用整数尾数和指数作为模板参数…