[Rcpp-devel] module with vector<Mytype> when Mytype has children with inheritence

Robin Girard robin.girard at mines-paristech.fr
Tue Apr 2 13:15:56 CEST 2013

Hello list, 
I'm having troubles using module on a class that redefines a vector of Mytype where Mytype is type that has several children types. Mytype has only methods while cihldren inherit methods and have fields that are double or integer or string. 

- when I remove inheritance everything work fine. 
- with inheritance, when I remove the push_back function redeclaration everything works fine
- I am using the .derives in the module definitions

I understand that I fully fall into the known shortcomming annouced in the Rcpp module vignette, I have tryed to read more about wrap (where my problem seems to be) digging into RcppArmadillo and RcppGSL, but it's a bit over my level of understanding for now since I'm new to cpp and don't fully understand template programming. I would like to know if there is a simple workaround in my case. 

The end of the error message in case this helps (Mytype is consumptionMean): 

C:/R/R-2.15.2/library/Rcpp/include/Rcpp/internal/wrap.h:882:96:   instantiated from 'SEXPREC* Rcpp::module_wrap(const T&) [with T = consumptionMean, SEXP = SEXPREC*]'
C:/R/R-2.15.2/library/Rcpp/include/Rcpp/module/Module_generated_CppMethod.h:104:138:   instantiated from 'SEXPREC* Rcpp::CppMethod1<Class, OUT, U0>::operator()(Class*, SEXPREC**) [with Class = consumptionMean_vec, OUT = consumptionMean, U0 = int, SEXP = SEXPREC*]'
Mymodules.cc:84:1:   instantiated from here
C:/R/R-2.15.2/library/Rcpp/include/Rcpp/internal/wrap.h:451:11: error: passing 'const consumptionMean' as 'this' argument of 'consumptionMean::operator SEXP()' discards qualifiers


Dr. Girard Robin
Chargé de Recherche

MINES-ParisTech / Département Energétique et Procédés / PERSEE / Groupe ERSEI
Centre Procédés, Energies Renouvelables et Systèmes Energétiques (PERSEE)
Center for Processes, Renewables Energies and Energy Systems
Renewable Energies & Smartgrids (ERSEI)

1 Rue Claude Daunesse - CS 10207 - F-06904 Sophia Antipolis Cedex
Tel: + (~99), Fax: +
e-mail : robin.girard at mines-paristech.fr

web page perso http://www.mines-paristech.fr/Services/Annuaire/&?id=8828
statoverflow : http://stats.stackexchange.com/users/223/robin-girard
web page centre PERSEE : http://www.cep.mines-paristech.fr/
linkedin : http://www.linkedin.com/profile/view?id=14907272&trk=tab_pro

Le lien vaut mieux que le bien.

CONFIDENTIALITY : This  e-mail  and  any attachments are
confidential and may be privileged. If  you are not a
named recipient, please notify the sender immediately and
do not disclose the contents to another person, use it for
any purpose or store or copy the information in any medium.

CONFIDENTIALITE : Ce message et les éventuelles pièces
attachées sontconfidentiels et peuvent être une
communication protégée. Si vous n'êtes pas dans la liste
des destinataires, veuillez informer l'expéditeur
immédiatement et ne pas ouvrir ni divulguer le contenu
à une tierce personne, ne pas l'utiliser pour quelque
raison que ce soit, ne pas stocker ou copier l'information
qu'il contient sur un quelconque support.

More information about the Rcpp-devel mailing list