GCC error: explicit specialization in non-namespace scope

前端 未结 2 2117
灰色年华
灰色年华 2020-12-08 10:02

I am trying to port the following code. I know the standard doesn\'t allow explicit specialization in non-namescape scope and I should use overloading, but I just can\'t fin

2条回答
  •  温柔的废话
    2020-12-08 10:49

    Define the specialization outside the class as:

    template <> 
    bool VarData::IsTypeOf < int > (int index) const 
    {  //^^^^^^^^^ don't forget this! 
         return false;
    }
    
    template <> 
    bool VarData::IsTypeOf < double > (int index) const 
    {   //^^^^^^^ don't forget this!
         return false;
    }
    

提交回复
热议问题