title: Template function accepting callable functors with X parameters
body: <p>I'm writing a hosted C++ program that runs user-written C-code compiled on the fly. It's absolutely vital that certain typical exceptions are caught from the C-code and processed/ignored.
  To do this, I'm calling the C code from within a structured exception handling block. Due to the nature and semantics of this block (and where it's called from), I've separated the actual calling to it's own function:</p>
  
  <pre><code>    template &lt;typename ret_type, class func&gt;
          static ret_type Cstate::RunProtectedCode(func function) {
              ret_type ret = 0;
              __try {
                  ret = function();
              }
              __except(ExceptionHandler(GetExceptionCode(), ExceptionStatus::CSubsystem)) {
                  fprintf(stderr, "First chance exception in C-code.\n");
              }
              return ret;
          }
  </code></pre>
  
  <p>Which works nicely as it should like so:</p>
  
  <pre><code>        RunProtectedCode&lt;int&gt;(entry);
  </code></pre>
  
  <p>But is it possible to shape this so i can call functions with variable amounts of parameters - maybe through some use of exotic functors (only requirement is obviously that it can't have a destructor)? I'm using MSVC++ 2010.</p>