小编TRP*_*RPh的帖子

这篇 cppreference.com 文章的结尾有问题

我已阅读模板的隐式专业化意味着什么?及其答案,但我仍然不满意我从 cppreference.com理解部分模板专业化的这一部分:

如果主要成员模板显式(完全)专门用于封闭类模板的给定(隐式)特化,则对于封闭类模板的这种特化,成员模板的部分特化将被忽略......

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
Run Code Online (Sandbox Code Playgroud)

问题:

  1. 评论说该行template<> template<classT2> …

c++ templates specialization

6
推荐指数
1
解决办法
72
查看次数

标签 统计

c++ ×1

specialization ×1

templates ×1