Ram
Ram

Reputation: 3133

Explicit member function specialisation

I am unable to specialize the template member function below. I have looked at the solution given to answer similar question on SOF but the solution that is proposed is same as the code I have below but it does not seem to work. I am missing something for sure.

    enum EStep
    {
         eStep1, eStep2, eStep3
    };
    template<int16_t iDevice>
    struct Device
    {
        template<EStep step>
        static constexpr bool isType() { return false; }
    };

    template<> template<>
    constexpr bool Device<int16_t>::isType<eStep1>()
    {
        return true;
    }

Upvotes: 0

Views: 37

Answers (1)

gchen
gchen

Reputation: 1173

template<> template<>
constexpr bool Device<int16_t>::isType<eStep1>()
{
    return true;
}

Device is a template of int16_t, so to specialize it, you'd need to provide an int16_t value as the template argument. e.g.

template<> template<>
constexpr bool Device<999>::isType<eStep1>()

Upvotes: 1

Related Questions