C++: Nested template classes error “explicit specialization in non-namespace scope”

后端 未结 1 1685
刺人心
刺人心 2020-12-05 07:20

The following code:

template 
struct A1
{
  template 
  struct A2 { /* ... */ };

  template <>
  struct A2<-1>          


        
相关标签:
1条回答
  • 2020-12-05 07:55

    It is not allowed to explicitly specialize A2 without specializing A1 (§14.7.3/18). C++0x has the same restriction (n3242 §14.7.3/16). At the same moment a partial specialization of a nested class is allowed. So the trick with a dummy class is Ok.

    0 讨论(0)
提交回复
热议问题