Template specialization of a single method from templated class with multiple template parameters

故事扮演 提交于 2019-11-29 15:24:26

You have to specialize the entire class before you define a method through a partial specialization:

template <typename T, typename U>
class TClass;

template <typename T>
class TClass<int, T>
{
    void doSomething(int* v);
};

template <typename T>
void TClass<int, T>::doSomething(int* v)
{
    // ...
}

Live demo

You can fully specialize class method but as far as I remember you can't partially specialize it.

You can try partial specialization for the whole class but this will probably involve a lot of duplication.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!