[Rcpp-devel] Copying a NumericVector from a list within a list
Krzysztof Sakrejda
krzysztof.sakrejda at gmail.com
Sun Apr 13 17:18:04 CEST 2014
Sorry, accidental gmail send... here's what I meant:
On Sat, Apr 12, 2014 at 11:06 PM, Dirk Eddelbuettel <edd at debian.org> wrote:
> What can work as a single expression in R sometimes needs to be disentangled
> at the C++ level to help the compiler find its way through all the templates.
>
[snip]
>
> // [[Rcpp::export]]
> NumericVector fromList(List outer, std::string name) {
> List inner = outer[0]; // 0-based offsets in C++
> return inner["p"];
> }
I've noticed (I think...) having to do this sort of thing, but I want
to ask a question to clarify: is it possible to have the above code
work, but if you instead try:
NumericVector fromList(List outer, std::string name) {
return (outer[0])["p"];
}
or even:
NumericVector fromList(List outer, std::string name) {
NumericVector vec = (outer[0])["p"];
return vec;
}
It will fail to compile? That's what you mean by needing to "help the
compiler"? If so,
is there some terminology for these sorts of problems?
Krzysztof
More information about the Rcpp-devel
mailing list