1

I'm porting some MSVC code which I wrote to GCC but it failed to compile on GCC (see: 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;
}

For some reason, GCC doesn't like the way I'm passing op through to other template functions.

songyuanyao
  • 169,198
  • 16
  • 310
  • 405
Zach Saw
  • 4,308
  • 3
  • 33
  • 49

1 Answers1

4

You need to use the template keyword for Do, which is a function template. e.g.

UnrolledOp<fooSize / 4>::template Do<0, op>(foo, l, r);
//                       ~~~~~~~~

LIVE

songyuanyao
  • 169,198
  • 16
  • 310
  • 405