[Rcpp-devel] wrap

Romain Francois romain.francois at dbmail.com
Mon Feb 1 12:07:28 CET 2010


Hi,

I've finally discovered the is_convertible type trait (from tr1 or 
C++0x) which helps closing the implementation of wrap.

Here are the types that can currently be wrapped

int
size_t
double
bool
std::string
const char* const
Rbyte
Rcomplex

Additionally, if the type T can be wrapped, then the following types can 
also be wrapped:

std::vector<T>
std::deque<T>
std::list<T>
std::set<T>
std::multiset<T>
std::map<std::string,T>
std::multimap<std::string,T>

std::tr1::unordered_set<T>
std::tr1::unordered_map<std::string,T>
std::tr1::unordered_multimap<std::string,T>

Additionally, type Foo can be wrapped if it can be implicitely converted 
to SEXP, which we can identify at compile time with is_convertible.

Note that you can compose in any way you want, so for example:

std::vector< std::map<std::string,std::vector<int> > >

will happily be wrapped into a list of named lists of integer vectors. 
There are examples of this in the unit test runit.wrap.R. The 
implementation of this is contained in the Rcpp/internal/wrap.h file.

Romain

-- 
Romain Francois
Professional R Enthusiast
+33(0) 6 28 91 30 30
http://romainfrancois.blog.free.fr
|- http://tr.im/KfKn : Rcpp 0.7.2
|- http://tr.im/JOlc : External pointers with Rcpp
`- http://tr.im/JFqa : R Journal, Volume 1/2, December 2009




More information about the Rcpp-devel mailing list