The following code does not compile:
// [[Rcpp::plugins(cpp11)]]
// [[Rcpp::depends(RcppParallel,BH)]]
#include <Rcpp.h>
#include <RcppParallel.h>
#include <cassert>
using RcppParallel::RMatrix;
//[[Rcpp::export]]
void Test() {
double buffer[10] = {1,2,3,4,5,6,7,8,9,10};
RMatrix<double> mtx(&buffer[0], 2,5); // compilation error: invalid cast `const double*` to `double*` in ctor
assert (mtx(0,0) == 1);
mtx(0,0)=77;
assert (mtx(0,0) == 77);
}
I believe there is nothing wrong for the RMatrix constructor to accept a non-const pointer to the data buffer; i prepared and submitted a PR (#138).
The following code does not compile:
I believe there is nothing wrong for the RMatrix constructor to accept a non-const pointer to the data buffer; i prepared and submitted a PR (#138).