C++11 显式成员函数专业化
我无法专门化下面的模板成员函数。我已经看过了回答SOF类似问题的解决方案,但提出的解决方案与下面的代码相同,但似乎不起作用。我肯定错过了一些东西C++11 显式成员函数专业化,c++11,templates,template-specialization,C++11,Templates,Template Specialization,我无法专门化下面的模板成员函数。我已经看过了回答SOF类似问题的解决方案,但提出的解决方案与下面的代码相同,但似乎不起作用。我肯定错过了一些东西 enum EStep { eStep1, eStep2, eStep3 }; template<int16_t iDevice> struct Device { template<EStep step> static constex
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;
}
Device是int16_t的模板,所以要专门化它,需要提供一个int16_t值作为模板参数。e、 g
template<> template<>
constexpr bool Device<999>::isType<eStep1>()
我认为没有部分模板专业化。我也得为国际比赛做这件事。谢谢
template<> template<>
constexpr bool Device<999>::isType<eStep1>()