我有一行看起来如下:
F::enable<sizeof(value_type), offset>(index);
Run Code Online (Sandbox Code Playgroud)
我得到以下编译器错误(GCC 6.3.1):
error: invalid operands of types ‘<unresolved overloaded function type>’ and ‘long unsigned int’ to binary ‘operator<’
Run Code Online (Sandbox Code Playgroud)
显然,左尖括号被解释为小于运算符,而不是模板参数列表的开头.F是一个模板参数(F类),我希望它包含一个带签名的静态成员函数:
template <GLsizei stride, const GLvoid* offset>
static void enable(GLuint index);
Run Code Online (Sandbox Code Playgroud)
我试过自由地插入空格,查看typedeffing函数,看看转移到常规函数(由于继承的东西不可能).我已经注释掉了这条线,看看上面是否有什么东西引起了问题,没有骰子.有没有办法向编译器解释我不想比较函数和size_t,我想在类中调用静态成员函数的特定特化?
使用template关键字消除歧义:
F::template enable<sizeof(value_type), offset>(index);
Run Code Online (Sandbox Code Playgroud)