title: C++: Function pointer to functions with variable number of arguments
body: <p>I'm trying to figure out a way of how to be able to assign a function pointer to functions with different number of arguments. </p>
  
  <p>I have a while loop which takes a number of different functions as a conditional statement, so instead of writing multiple while loops with exactly the same code inside I'd like to have one with a function pointer. All the functions are of format <code>bool f(...)</code>. I think some code will best illustrate what I mean:</p>
  
  <pre><code>int a, b, c, d;
  MyClass* my_class;
  
  typedef bool (MyClass::*my_fun_t)();
  my_fun_t my_fun;
  
  if (condition1)
      my_fun = &amp;MyClass::function_one();
  else if (condition2)
      my_fun = &amp;MyClass::function_two(a, b);
  else if (condition3)
      my_fun = &amp;MyClass::function_three(a, b, c);
  else if (condition4)
      my_fun = &amp;MyClass::function_four(a, b, c, d);
  
  while ((my_class-&gt;*my_fun)()) 
  { ... }
  </code></pre>
  
  <p>Now this obviously doesn't work because the functions have different signatures. Is it at all possible to make it work in a similar fashion? Are functoids something I should look at? </p>