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

前端 未结 2 1682
天涯浪人
天涯浪人 2020-12-21 08:43

I\'m basically trying to do what was discussed in Template specialization of a single method from a templated class except that my TClass has multiple template Parameters li

相关标签:
2条回答
  • 2020-12-21 09:19

    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.

    0 讨论(0)
  • 2020-12-21 09:32

    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

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