Skip to content

Incompatability with Rcpp::clone #453

@halidaee

Description

@halidaee

I have a number of areas in my code where I am trying to make a deep copy of an arma::mat object, i.e.

arma::mat X = Rcpp::clone(inputs)

These are almost always clones of objects passed on as function inputs, i.e.

arma::mat next_W_func(const arma::mat& W_k) {
      arma::mat W_kmin1 = clone(W_k);
}
// code to change W_k

Every instance I try adding Rcpp::clone to my code results in the following error during build:

/open/programs/miniconda3/envs/r_env/lib/R/library/Rcpp/include/Rcpp/clone.h: In instantiation of 'T Rcpp::clone(const T&) [with T = arma::Mat<double>]':
demo.cpp:79:30:   required from here
   79 |     arma::mat X = Rcpp::clone(inputs);
      |                   ~~~~~~~~~~~^~~~~~~~
/open/programs/miniconda3/envs/r_env/lib/R/library/Rcpp/include/Rcpp/clone.h:34:18: error: no matching function for call to 'Rcpp::Shield<SEXPREC*>::Shield(arma::Mat<double>&)'
   34 |     Shield<SEXP> x(const_cast<T&>(object));
      |                  ^
// error continues very long trace after here.

I'm wondering if there is some incompatibility with this package and Rcpp?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions