我正在移植一些MSVC代码,这些代码是我编写到GCC的,但在GCC上编译失败(请参阅:
https://ideone.com/UMzOuE
)。
template <const int N>
struct UnrolledOp
{
template <const int j, int op(int*, int*)>
static void Do(int* foo, int* l, int* r)
{
return UnrolledOp<N - 1>::Do<j + 4, op>(foo, l, r);
}
};
template <>
struct UnrolledOp<0>
{
template <const int j, int op(int*, int*)>
static void Do(int* foo, int* l, int* r) { }
};
template <const int fooSize, int op(int*, int*)>
void Op(int* foo, int* l, int* r)
{
UnrolledOp<fooSize / 4>::Do<0, op>(foo, l, r);
}
int Test(int* x, int* y)
{
return 0;
}
int main()
{
Op<16, Test>(nullptr, nullptr, nullptr);
return 0;
}
出于某种原因,GCC不喜欢我通过的方式
op
到其他模板函数。