Skip to content
Prev 9986 / 10988 Next

[Rcpp-devel] coercion NULL to vector

Le 18/04/2018 ? 13:32, Dirk Eddelbuettel a ?crit?:
I can describe my own case which made me search for a such solution.
I have an Rcpp/Armadillo function accepting in an optional argument a vector of uvec type.
It can be called from R and I can call it from other C++ functions of the same package too.
Nullable<IntegerVector> mechanism was cumbersome but sufficient (note that there is no possible Nullable<uvec>)
when only R calls were planned. But when it comes to calls from C++ I'll have to juggle with wrap() too.
Both of Nullable<T> (as well as special code for dealing with NULL case) and wrap()
become unnecessary with a neat declaration f(..., uvec v, ...). So that
an R call with 'c()' can pass as well as C++ calls with an empty uvec without
any additional hassle for treating NULL case.

Serguei.