我有以下的模板类:类模板参数推断与构造
template <typename T>
struct timer
{
T period;
timer(T p) :
period(p)
{}
};
初始化它,我需要做的事:
timer<double> t(double(0.0));
是可以提高timer
的类定义,允许此语法:
timer t(double(0.0));
并让编译器推断出double
类型从构造函数的参数?
检查出[为什么不从构造函数推断模板参数?](http://stackoverflow.com/questions/984394/why-not-infer-template-parameter-from-constructor)为同一问题 –