title: Is there a way to check the arity of Rcpp::Function?
body: <p>I need to check the arity of a function in an Rcpp block at run time. What I would like to do is something akin to the following:</p>
  <pre><code>double loglikelihood(Rcpp::List data, Rcpp::List params, SEXP i, Rcpp::RObject custom_function) {
      Rcpp::Function f = Rcpp::as&lt;Rcpp::Function&gt;(custom_function);
      double res = 0.0;
      if (arity(f) == 3) {
          res = Rcpp::as&lt;double&gt;(f(data, param, i));
      } else if (arity(f) == 2) {
          res = Rcpp::as&lt;double&gt;(f(data, param));
      }
      return res;
  }
  </code></pre>
  <p>However, the limited documentation I've seen for Rcpp does not seem to contain a function for checking the arity of an Rcpp::Function. Is there any way to do this?</p>