[Rcpp-devel] Call by reference
Rguy
rguy at 123mail.org
Tue Jul 28 18:53:30 CEST 2015
I attempted to implement the call by reference example on page 200 of
Seamless R and C++, as follows:
#include <Rcpp.h>
using namespace Rcpp;
// [[Rcpp::export]]
void absC(double & x) {
if (x < 0) x = -x;
}
/*** R
x = -1
absC(x)
x
*/
Unfortunately, x remains equal to -1.
Platforms: Windows 7, "R version 3.1.3 Patched (2015-03-16 r68103)".
Please advise.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20150728/41fb2c4c/attachment.html>
More information about the Rcpp-devel
mailing list