[Rcpp-devel] Deriving type information

Kevin Ushey kevinushey at gmail.com
Fri Feb 14 00:49:48 CET 2014

Hi Søren,

You want to use Rcpp's traits. I don't think these are explicitly
documented anywhere, although there are a few examples on the gallery
demonstrating their usage (e.g.

In this case, you can use


to extract the type. Typically, using a typedef makes it easiest, so I
would write something like:

    typedef typename traits::storage_type<RTYPE>::type storage_t;
    storage_t a = x[0];

Once you understand the general pattern, it's pretty easy to just read
and understand the traits available at
but perhaps this would be a good gallery post.

For more information, I thought this was a pretty good introductory
article on understanding C++ traits:


More information about the Rcpp-devel mailing list