以下给出MSVC++ 10 Sp1上的“内部编译器错误”。部分和显式模板专门化的奇怪错误
而上的gcc:
b.cpp:16:12:错误:在非命名空间范围显式特 '结构A :: B'
b.cpp:16:28:错误:模板id初级模板的声明“F”
//class template
template< class T>
struct A{
//struct B {}; //Remove the comment and it will compile!
};
//partial specialization
template< class T >
struct A< T* >
{
struct B {
template<class C> void f(){}
//"Internal Compiler Error"
template<> void f<int>(){};
};
};
但是,如果struct B
之前的评论被删除它会编译!
我不明白这个问题!
首先,它不应该编译。你应该提交一份错误报告。这里没有问题,我们也无法解释我们没有来源的代码中的错误。 –
这也不应该与删除的评论编译。 –
[模板类中的模板函数的显式特化的C++语法的可能的重复?](http://stackoverflow.com/questions/2097811/c-syntax-for-explicit-specialization-of-a-template-function -in-a-template-clas) –