[Rcpp-devel] Template argument deduction with R objects

Dirk Eddelbuettel edd at debian.org
Sun Oct 14 01:34:28 CEST 2018

On 14 October 2018 at 02:11, Vissarion Fisikopoulos wrote:
| Hi Qiang,
| thanks for the quick reply! "TYPEOF" is runtime right? I want
| something compile time,
| i.e. depending on the type of the R object deduce a type to be fed to
| a templated function.

In short, you can't. 

R only has one type, so to speak -- SEXP -- and you need to decide at
run-time _what type it may carry_.

See eg


as well as several answers on StackOverflow and in the list archives.

Because R allows     a <- 1L;  myFunc(a)     as well as other variable for a,
this does not map so well.  Such is life when interfacing a dynamic language.


http://dirk.eddelbuettel.com | @eddelbuettel | edd at debian.org

More information about the Rcpp-devel mailing list