3

What is the issue here?

struct fbe {
    char *fbtName;
    template<typename T, typename... vT> 
    T(*funcptr)(T, vT... );
};

And what is the difference that made it compile when writing like this?

template<typename T, typename... vT>
struct fbe {
    char *fbtName;
    T(*funcptr)(T, vT... );
};

I am very new to using template functions.

Bo Persson
  • 90,663
  • 31
  • 146
  • 203
kar
  • 495
  • 1
  • 8
  • 19
  • Basically you cannot have templated member variables. For why that is the case, Bo Persson answers it quite well. – AndyG Jan 08 '16 at 15:16

1 Answers1

9

The difference is that in the second case you can use the template parameters to create a set of different structs, all having a single function pointer member.

In the first case, you would have a single struct type with an infinite number of function pointer members. You cannot have that, if nothing else because all objects of the same struct type must have the same size.

Bo Persson
  • 90,663
  • 31
  • 146
  • 203