【发布时间】:2014-03-28 19:23:28
【问题描述】:
所以我有以下代码:
template <typename Type>
class Delegate
{
public:
Delegate(Type x)
{
}
};
void Method()
{
}
int main()
{
Delegate d(&Method);
return 0;
}
我的问题是:为什么编译器不能根据传入构造函数的内容推断模板类型?我得到的编译错误是:Argument list for class template Delegate is missing. 我明白这一点,但我认为类型推断可以克服这个问题以允许更清晰的语法。
【问题讨论】:
-
我理解错误,我只是对构造函数不能使用类型推断感到惊讶并且想知道为什么。谢谢。
-
朱普。错过了最后一句话。已经删除了我的评论:)
标签: c++ templates constructor variadic-templates