Specialization of templated member function in templated class

前端 未结 2 941
情歌与酒
情歌与酒 2020-11-28 14:32

I have a templated class with an templated member function

template
class A {
public:
    template
    CT function();
};
         


        
2条回答
  •  独厮守ぢ
    2020-11-28 15:04

    Yes, this is the problem:

    error: enclosing class templates are not explicitly specialized 
    

    You cannot specialize a member without also specializing the class.

    What you can do is put the code from function in a separate class and specialize that, much like basic_string depends on a separate char_traits class. Then then non-specialized function can call a helper in the traits class.

提交回复
热议问题