Hi,

I'm writing a R package by Rcpp and I have a problem when setting default
value when call a R function in Rcpp. Here is an example to pass a R
function to C++, provided by http://adv-r.had.co.nz/Rcpp.html

#include <Rcpp.h>using namespace Rcpp;// [[Rcpp::export]]RObject
callWithOne(Function f) {
  return f(1);}

The question is, how to set the default value for f? I would like to have
the choice to pass a function or not, like

callWithOne(Function f = NULL) {
  // if pass f, run f(1)
  // else, run something else}


Thanks!

Best,
Jingyu He
_______________________________________________
Rcpp-devel mailing list
Rcpp-devel@lists.r-forge.r-project.org
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel

Reply via email to