In C++, we can declare a variable as a reference.
int a = 10;
int& b = a;
If we set b=15
, a
also changes.
I want to do the similar thing in Rcpp.
List X = obj_from_R["X"];
IntegerVector x_i = X[index];
x_i = value;
I want to update an object from R called X
by inserting a value to one of its vector. The code above did not work, so I tried this:
IntegerVector& x_i = X[index];
and received an error.
error: non-const lvalue reference to type 'IntegerVector'
(aka 'Vector<13>') cannot bind to a temporary of type 'Proxy' (aka 'generic_proxy<19>')
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…