In fact, I'm going to go against everyone here, and your desire.
The ellipsis is wrong. This was considered indispensable in C, but since then we have learned better.
In fact, in C ++ there are actually better ways to use objects and, for example, function objects.
What you are looking for is a Command Pattern .
Create a base class called "Command" (an interface with the execute () method), then for each of the "functions" that you would like to add to "void (* func) ()", you create a derived class.
Your code will now look like this:
std::vector<RESULT*> param(10, NULL); if (Root->Function->argc < 0) { Command1* aCommand = new Command1(Root->Result); aCommand->set(Root->Result, argc, ¶m); Root->Function->command = aCommand; Root->Function->command->execute(); } else { Command2* aCommand = new Command2(Root->Result); aCommand->set(Root->Result, param[0], param[1], param[2], param[3], param[4], param[5], param[6], param[7], param[8], param[9]); Root->Function->command = aCommand; Root->Function->command->execute(); }
Here you donβt need ellipsis, because each command object is specialized and knows exactly what parameters it needs (number and types).
The command template allows you to take full advantage of the "..." (ellipsis) without its inconvenience. Well, of course, some will say that itβs a waste of time, since they donβt make mistakes, so they donβt need to enter more ... unfortunately, I'm not so smart, so I prefer to define restrictions (quantity, types, statements), and let the compiler provide them for me.