[Rcpp-devel] Picking off a matrix-valued list element inside a class constructor?
Darren Cook
darren at dcook.org
Sun Oct 23 10:20:09 CEST 2011
> Rcpp::IntegerMatrix m = l["m"];;
> ...
> This seems to work just fine.
> ... the seemingly equivalent statement in the body of a class
> constructor fails with a compilation error:
> ...
> CCC(Rcpp::List l){
> m = l["m"];
> }
In C++, the left side can sometimes give a hint about how the right-side
should be interpreted. When I changed the constructor body to this it
worked:
Rcpp::IntegerMatrix tmp=l["m"];
m = tmp;
I tried a few ideas to get a one-liner that does the same... and
couldn't; perhaps someone else knows the magic syntax?
(For reference these were what I tried:
m =Rcpp::IntegerMatrix(l["m"]);
m =(Rcpp::IntegerMatrix)l["m"];
m.operator=<Rcpp::IntegerMatrix>(l["m"]);
)
> [...]
> private:
> Rcpp::IntegerMatrix m;
> } <-- NEED SEMI-COLON HERE
> '
BTW, you are missing a semi-colon after the closing bracket for your class.
Darren
--
Darren Cook, Software Researcher/Developer
http://dcook.org/work/ (About me and my work)
http://dcook.org/blogs.html (My blogs and articles)
More information about the Rcpp-devel
mailing list