为什么模板专业化中的显式实例化会给我错误?

Why explicit instantiation in template specialization is giving me error?

考虑代码:

...
template <typename T>
void Swap(T &,T &);
template <> void Swap<structEmployee>(structEmployee &,structEmployee &);
int main()
{
template void Swap<char>(char &,char &);
short a=10,b=20;
...
Swap(a,b);
...
...
}

给我的错误是:

expected primary-expression before ‘template’
 template void Swap<char>(char &, char &);

您不能在块范围内实例化模板,它必须在全局范围内:

//Instantiation in global scope
template void Swap<char>(char &,char &);

int main()
//...