r-lib / cpp11

cpp11 helps you to interact with R objects using C++ code.
https://cpp11.r-lib.org/
Other
193 stars 46 forks source link

Can't copy proxy elements between writable vectors #300

Open DavisVaughan opened 1 year ago

DavisVaughan commented 1 year ago

This seems fairly restrictive? I feel like you should be able to copy proxy elements of the same type from one writable vector to another.

cpp11::cpp_function("

cpp11::writable::doubles test() {
  cpp11::writable::doubles x({1, 2, 3});
  cpp11::writable::doubles y({4, 5, 6});

  for (R_xlen_t i = 0; i < x.size(); ++i) {
    y[i] = x[i];
  }

  return y;
}

")
#> object of type 'cpp11::writable::r_vector<double>::proxy' cannot be assigned because its copy assignment operator is implicitly deleted
#>     y[i] = x[i];
#>  copy assignment operator of 'proxy' is implicitly deleted because field 'data_' is of const-qualified type 'const SEXP' (aka 'SEXPREC *const')
#>     const SEXP data_;
#> error generated.
#> make: *** [/private/var/folders/41/qx_9ygp112nfysdfgxcssgwc0000gn/T/Rtmpp0Qrcn/code_13be14d8f81cc.o] Error 1
#> make: *** Waiting for unfinished jobs....
#> Error: Compilation failed.

Created on 2022-11-11 with reprex v2.0.2.9000