以下代码在 Xcode 中生成编译错误:
template <typename T>
struct Foo
{
Foo(T Value)
{
}
};
int main()
{
Foo MyFoo(123);
return 0;
}
error: missing template arguments before 'MyFoo'
更改Foo MyFoo(123);
以Foo<int> MyFoo(123);
解决问题,但编译器不应该能够找出适当的数据类型吗?
这是编译器错误,还是我误解了隐式模板参数?