0

I have the following class:

template <typename T>
struct MyStruct
{
    template <typename FunType>
    void fun(size_t idx)
    {
        if (idx == 0)
            return;

        MyStruct<FunType> obj;
        obj.fun<FunType>(idx - 1);
    }
};

Compiling this piece of code produces the following error:

error: expected primary-expression before '>' token
  obj.fun<FunType>(idx - 1);
                 ^

Strangely, changing the line MyStruct<FunType> obj; to e.g. MyStruct<int> obj; (or any other type except FunType) seems to solve the problem. Can somebody explain to me what is going on?

Thanks in advance!

Jasper Koning
  • 143
  • 1
  • 9

0 Answers0