c++ template partial specialization member function [duplicate]

You cannot partially specialize only a single member function, you must partially specialize the whole class. Hence you’ll need something like:

template <typename T>
class Object<T, 0>
{
private:
    T m_t;
    Object();
public:
    Object(T t): m_t(t) {}
    T Get() { return m_t; } 
    Object& Deform()
    {
        std::cout << "Spec\n";
        m_t = -1;
        return *this;
    }
};

Leave a Comment