5
考虑下面的例子:专业化模板函数
#include <iostream>
template< int a >
void foo();
int main(int argn, char* argv[])
{
foo<1>();
}
template<>
void foo<1>()
{
std::cout<<1<<std::endl;
}
编译失败,接下来的错误消息:
rg.cpp:12: error: specialization of ‘void foo() [with int a = 1]’ after instantiation
什么款的标准解释了这个错误?
PS:我知道如果我移动main前面的函数定义会使错误消失。
+1为第二个报价。我正在寻找那个。 – Nawaz 2011-05-06 14:32:05
是的,我正在寻找14.7.3。谢谢 – 2011-05-06 14:33:41