On 11 August 2016 at 11:05, Rajen Shah wrote:
| I realise there is a helpful section on this in
| 
| https://cran.r-project.org/doc/manuals/r-release/R-exts.html#
| Checking-memory-access
| 
| which I'm now reading.

We generally shield you from this.  That is, you create objects without
having to worry about.  But a) casts (particularly implicit ones) and b) the
wrap() return business are really complicated.

If you err on the side of caution everything works:

R> cppFunction("IntegerVector myrunif() { NumericVector x = 
floor(runif(1000000)); return as<IntegerVector>(x); }")
R> for (i in 1:100) ignoreme <- myrunif()
R> 

Here we start with the numeric vector, then cast to an integer vector which
is what is returned.

Dirk

-- 
http://dirk.eddelbuettel.com | @eddelbuettel | e...@debian.org
_______________________________________________
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