问题描述
我已经阅读了What does template's implicit specialization mean?及其答案,但仍然不满意我从cppreference.com了解Partial template specialization的这一部分:
如果主要成员模板明确地(完全)专门用于封闭类模板的给定(隐式)专业化,则成员模板的部分专门性将被忽略。 >
template<class T> struct A { //enclosing class template template<class T2> struct B {}; //primary member template template<class T2> struct B<T2*> {}; // partial specialization of member template }; template<> template<class T2> struct A<short>::B {}; // full specialization of primary member template // (will ignore the partial) A<char>::B<int*> abcip; // uses partial specialization T2=int A<short>::B<int*> absip; // uses full specialization of the primary (ignores partial) A<char>::B<int> abci; // uses primary
问题:
-
评论说
template<> template<classT2> struct A<short>::B {};
行是“主要成员模板的完全专业化”。主要成员模板在注释中标识为结构B
。当行B
被A
替换为short
时,该行怎么能成为class T
的专业化? -
在未指定模板参数
B
的情况下,该行如何成为T2
的“完全”专长? -
注释和随附的文字表明“显式专业化”和“完全专业化”是同义词。如果上面引用的代码行是
B
的显式专业化,那么A
的隐式专业化在哪里?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)