Re: [Rcpp-devel] Module with vector of a class with inheritance, how to avoid slicing

2013-04-04 Thread Dirk Eddelbuettel
On 4 April 2013 at 12:45, Krzysztof Sakrejda wrote: | I realize you did not ask for book suggestions, but a gentle walk | through all these C++ issues (Slicing, constructors/destructors, and | the joy of pointers) is contained in Koenig & Moo's "Accelerated C++: | practical programming by example.

Re: [Rcpp-devel] Module with vector of a class with inheritance, how to avoid slicing

2013-04-04 Thread Krzysztof Sakrejda
De: "Robin Girard" > À: "Romain Francois" > Cc: rcpp-devel@lists.r-forge.r-project.org > Envoyé: Jeudi 4 Avril 2013 18:08:50 > Objet: Re: [Rcpp-devel] Module with vector of a class with inheritance, how > to avoid slicing > > that works indeed :) > R. &

Re: [Rcpp-devel] Module with vector of a class with inheritance, how to avoid slicing

2013-04-04 Thread Romain Francois
have something like res$whoAmI(1) Good luck - Mail original - De: "Robin Girard" À: "Romain Francois" Cc: rcpp-devel@lists.r-forge.r-project.org Envoyé: Jeudi 4 Avril 2013 18:08:50 Objet: Re: [Rcpp-devel] Module with vector of a class with inheritance, how to a

Re: [Rcpp-devel] Module with vector of a class with inheritance, how to avoid slicing

2013-04-04 Thread Robin Girard
2013 18:08:50 Objet: Re: [Rcpp-devel] Module with vector of a class with inheritance, how to avoid slicing that works indeed :) R. - Mail original - De: "Romain Francois" À: "Robin Girard" Cc: rcpp-devel@lists.r-forge.r-project.org Envoyé: Jeudi 4 Avril 2013 17:5

Re: [Rcpp-devel] Module with vector of a class with inheritance, how to avoid slicing

2013-04-04 Thread Robin Girard
that works indeed :) R. - Mail original - De: "Romain Francois" À: "Robin Girard" Cc: rcpp-devel@lists.r-forge.r-project.org Envoyé: Jeudi 4 Avril 2013 17:58:42 Objet: Re: [Rcpp-devel] Module with vector of a class with inheritance, how to avoid slicing Le 0

Re: [Rcpp-devel] Module with vector of a class with inheritance, how to avoid slicing

2013-04-04 Thread Romain Francois
- Mail original - De: "Romain Francois" À: rcpp-devel@lists.r-forge.r-project.org Cc: "Robin Girard" Envoyé: Mercredi 3 Avril 2013 22:12:48 Objet: Re: [Rcpp-devel] Module with vector of a class with inheritance, how to avoid slicing Hi, Fasten your seatbelts. First, the

Re: [Rcpp-devel] Module with vector of a class with inheritance, how to avoid slicing

2013-04-04 Thread Robin Girard
in R... but loops in R are like uses of Calloc with Rcpp no ? they are possible but if we can avoid them ... - Mail original - De: "Romain Francois" À: rcpp-devel@lists.r-forge.r-project.org Cc: "Robin Girard" Envoyé: Mercredi 3 Avril 2013 22:12:48 Objet: Re

Re: [Rcpp-devel] Module with vector of a class with inheritance, how to avoid slicing

2013-04-03 Thread Romain Francois
Please note that this is the "in progress" section of modules, so things can change. There are probably open questions. e.g. at the moment you have to deal with who is responsible for the pointers. Le 03/04/13 22:12, Romain Francois a écrit : Hi, Fasten your seatbelts. First, the problem i

Re: [Rcpp-devel] Module with vector of a class with inheritance, how to avoid slicing

2013-04-03 Thread Romain Francois
Hi, Fasten your seatbelts. First, the problem is definitely object slicing. The best resource I know about to explain it is a chapter of Scott Meyers "Effective C++". Robin, I would highly recommend that you get it. Specially considering that you are willing to get your hands dirty. Anyway,

Re: [Rcpp-devel] Module with vector of a class with inheritance, how to avoid slicing

2013-04-03 Thread Robin Girard
oups wrong, suppress my last message. R. - Mail original - De: "Robin Girard" À: rcpp-devel@lists.r-forge.r-project.org Envoyé: Mercredi 3 Avril 2013 20:07:14 Objet: Re: [Rcpp-devel] Module with vector of a class with inheritance, how to avoid slicing additional remark : i

Re: [Rcpp-devel] Module with vector of a class with inheritance, how to avoid slicing

2013-04-03 Thread Dirk Eddelbuettel
Robin, Section 'Known Shortcomings' in the Rcpp-modules vignette says \item mulitple inheritance: currently, only simple class structures are representable via \textsl{Rcpp modules}. If you want multiple inheritance you may need to let go of modules. Unless of course Romain has another p

Re: [Rcpp-devel] Module with vector of a class with inheritance, how to avoid slicing

2013-04-03 Thread Robin Girard
additional remark : if operator SEXP() ; is added to class father, children1_t, and children2_t the solution with XPtr compiles but gives the same result as the solution with shared_ptr (i.e. slicing) R. - Mail original - De: "Robin Girard" À: rcpp-devel@lists.r-forge.r-project.org C

[Rcpp-devel] Module with vector of a class with inheritance, how to avoid slicing

2013-04-03 Thread Robin Girard
I am still working on my vector of a class father with inheritance (polymorphic subclasses ?). I created an exemple below that works fine but I face the known problem of "slicing" as named here : http://stackoverflow.com/questions/10154977/c-vector-with-inheritance and fail to implement the pro