【发布时间】:2018-03-08 12:20:49
【问题描述】:
我正在移植一些我写到 GCC 的 MSVC 代码,但它无法在 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 传递给其他模板函数的方式。
【问题讨论】:
标签: c++ templates gcc g++ template-meta-programming