【发布时间】:2017-11-14 11:03:30
【问题描述】:
以下代码不起作用,它给出了一个错误,提示“struct foo 的模板参数太少”,我不明白为什么。对我来说,代码似乎应该是有效的。我在“参数列表”部分的第 4 段中从 CPP 参考 here 中找到了一个 sn-p,这可能解释了它为什么不起作用但我不明白。
template<int a, int b, int c> struct foo { };
template<int a> struct foo<a, 0, 0> { };
int main()
{
foo<1> f;
}
【问题讨论】:
标签: c++ templates metaprogramming template-meta-programming