我有以下包含模板函数的代码。当我使用第二个参数作为枚举调用此函数时:在某些情况下,它会找到模板专业化,而在某些情况下却没有。
我已经验证枚举在两种情况下都是相同的枚举(例如,没有重新定义)并且其他参数具有正确的值,我发现一个编译是使用 -Winline set 完成的(我还没有尝试更改它)还有什么看着?
class A {
public:
template <typename T>
int f(uint32_t id, T const& t, bool cond);
...
};
template <typename T>
int A::f(uint32_t id, T const& t, bool cond)
{
...
}
template <>
inline int A::f<int>(uint32_t, int const& t, bool cond)
{
....
}