Re: [Rcpp-devel] Passing template class as argument in Rcpp function

2021-03-04 Thread IƱaki Ucar
On Thu, 4 Mar 2021 at 20:31, Subhomoy Ghosh wrote: > > Thanks, for the solution. I tried what you suggested and it shows "no > matching constructor for initialization of 'Rcpp::XPtr'". Below > here is my attempt: > > class Distribution { > > public: > template > class Uniform2 { This is a

Re: [Rcpp-devel] Passing template class as argument in Rcpp function

2021-03-04 Thread Dirk Eddelbuettel
On 4 March 2021 at 14:31, Subhomoy Ghosh wrote: | @Dirk, Thanks! I am aware of the .Call(). I can go that route depending on | how it goes. I may not have been explicit enough. Everything we do goes that route, it's just that some of the code accessing it is written for you by Rcpp Attributes.

Re: [Rcpp-devel] Passing template class as argument in Rcpp function

2021-03-04 Thread Subhomoy Ghosh
Thanks, for the solution. I tried what you suggested and it shows "no matching constructor for initialization of 'Rcpp::XPtr'". Below here is my attempt: class Distribution { public: template class Uniform2 { public: Uniform2(T max_,mat D_) : max(max_), D(D_) {}

Re: [Rcpp-devel] Passing template class as argument in Rcpp function

2021-03-04 Thread Dirk Eddelbuettel
PS And building on top of my post and what Inaki told you, you can of course have C++ fancypants __provided the fancypants have something as for example the operator SEXP() in the Rcpp::Nullable(). In short, whatever you do, it (ultimately) has to convert to a SEXP or there is no calling from R.

Re: [Rcpp-devel] Passing template class as argument in Rcpp function

2021-03-04 Thread Dirk Eddelbuettel
Recall that R offers us a C language interface SEXP .Call("somename", SEXP a, SEXP b, ...); which imposes constraints on what you put there. I.e. no C++ fancypants. You can write yourself a _C_ function interface and pass your desired type as a string, or enum (i.e. int), or ... and then

[Rcpp-devel] Passing template class as argument in Rcpp function

2021-03-04 Thread Subhomoy Ghosh
Hi, This is related to my post . My question is in the same spirit except for one additional complexity. How can one create a new instance of a *template* class object