I also tried with (Handlers)[i]($arguments...) and also (Handlers)[i](...$arguments) and (Handlers)[i]($arguments), and it changes nothing, it still tells me too few arguments.Does anyone have experience with variadics?

0

Share this post

Link to post

Share on other sites

I don't understand what you expect this to do. You're trying to call a void (*)(int, float) with no arguments. Would you expect calling TestFunc with no arguments to work? Of course not, you need to give it an int and a float. Same with a function pointer that has int and float arguments. You probably want to modify operator() to accept arguments that you then pass to your handlers.

It tells me "arguments : undeclared identifier" and " '...' there are no parameter packs available to expand" I tried putting the dots on both sides.I actually had the "there are no parameter packs available to expand" once before when I first tried them out, but back then people said it's a Visual Studio problem, yet now I see people saying they actually got it to work.

EDIT: If I do: (Handlers)[i](3, 5.0f); then it works fine, so theproblem has to be in the syntax of (Handlers)[i](arguments...); , but I'm not quite sure what I'm doing wrong, all examples I found on the net do it like this (name ...)

Share this post

Link to post

Share on other sites

The outcome is the same when I rename them and remove the dollar symbol, maybe (Handlers)[i](parameters...);is just incorrect, but I tried writing it any way possible, still gives the same error.The only similar error I found in google was some old unanswered post.Maybe I should test the same code with GCC...

0

Share this post

Link to post

Share on other sites

It compiles fine for me if you either implement the function in the class definition instead of separating the class and the function definition, or if you specialize the implementation of operator() for Event<int, float>. Otherwise, I get the errors you mention.

works. I know the second one is not desired since you have to specify all the types you'll ever going to use. Could be that VS just doesn't handle variadic templates correctly since two other options work.