[Rcpp-devel] Wrapping std::vector<T> when Rcpp::wrap is user-overloaded for T

Nathanael Fillmore rcpp-devel at nate-fillmore.com
Wed Oct 14 05:28:07 CEST 2015


Hi Dirk,

> | However, compilation fails with the error messages pasted at the bottom of
> | the mail. My questions are as follows: Am I making an obvious mistake here
> | somewhere? Or, if not, is there some way to achieve this? Obviously, a
> | simple thing to do would be to write a Rcpp::wrap overloaded for
> | std::vector<std::pair<T, S>>, but that seems a bit inelegant.
>
> No, that would be my suggestion. You need to give the compiler something to
> match against.  The more specific, the better I'd say.
>
> (I may be overlooking something -- I just glanced at this as I am traveling
> right now.)

Thanks. I can do that. (The thing I have in fact done, which works, is
just not to use std::pair, and instead use my own type with operator
SEXP defined.)

However, it would be nice to also be able to wrap, e.g.,
std::set<std::pair<T, S>>, std::vector<std::vector<std::pair<T, S>>>,
etc., just like one could do if it std::pair<T, S> was replaced by
std::map<T, S> in these examples. It seems like this should
theoretically be possible for std::pair, given that it works for
std::map. However, I am not a template expert and have had trouble
following the library code.

Thanks,
Nate


More information about the Rcpp-devel mailing list