<html><body><div style="color:#000; background-color:#fff; font-family:lucida console, sans-serif;font-size:12pt"><div><span>Thanks, Darren. That worked well.</span></div><div><span><br></span></div><div><span>-- Mike</span></div><div><br><blockquote style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px;"><div style="font-size: 12pt; font-family: 'lucida console', sans-serif; "><div style="font-size: 12pt; font-family: 'times new roman', 'new york', times, serif; "><font size="2" face="Arial"><hr size="1"><b><span style="font-weight:bold;">From:</span></b> Darren Cook <darren@dcook.org><br><b><span style="font-weight: bold;">To:</span></b> rcpp-devel@r-forge.wu-wien.ac.at<br><b><span style="font-weight: bold;">Sent:</span></b> Sunday, October 23, 2011 1:20 AM<br><b><span style="font-weight: bold;">Subject:</span></b> Re: [Rcpp-devel] Picking off a matrix-valued list element inside a class
constructor?<br></font><br>
> Rcpp::IntegerMatrix m = l["m"];;<br>> ...<br>> This seems to work just fine.<br>> ... the seemingly equivalent statement in the body of a class<br>> constructor fails with a compilation error:<br>> ...<br>> CCC(Rcpp::List l){<br>> m = l["m"];<br>> }<br><br><br>In C++, the left side can sometimes give a hint about how the right-side<br>should be interpreted. When I changed the constructor body to this it<br>worked:<br> Rcpp::IntegerMatrix tmp=l["m"];<br> m = tmp;<br><br>I tried a few ideas to get a one-liner that does the same... and<br>couldn't; perhaps someone else knows the magic syntax?<br><br>(For reference these were what I tried:<br> m =Rcpp::IntegerMatrix(l["m"]);<br> m =(Rcpp::IntegerMatrix)l["m"];<br> m.operator=<Rcpp::IntegerMatrix>(l["m"]);<br>)<br><br>> [...]<br>>
private:<br>> Rcpp::IntegerMatrix m;<br>> } <-- NEED SEMI-COLON HERE<br>> '<br><br>BTW, you are missing a semi-colon after the closing bracket for your class.<br><br>Darren<br><br>-- <br>Darren Cook, Software Researcher/Developer<br><br>http://dcook.org/work/ (About me and my work)<br>http://dcook.org/blogs.html (My blogs and articles)<br>_______________________________________________<br>Rcpp-devel mailing list<br><a ymailto="mailto:Rcpp-devel@lists.r-forge.r-project.org" href="mailto:Rcpp-devel@lists.r-forge.r-project.org">Rcpp-devel@lists.r-forge.r-project.org</a><br><a href="https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel" target="_blank">https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel</a><br><br><br></div></div></blockquote></div></div></body></html>