On 5 March 2021 at 18:44, Iñaki Ucar wrote:
| Excellent. Note that the clone method was required for my use case, but it
| may be superfluous for yours.
It's very nice to do it straight up with the XPtr class.
A variant using Rcpp Modules is offerend byy RcppAnnoy -- also templated.
Dirk
--
h
Excellent. Note that the clone method was required for my use case, but it
may be superfluous for yours.
Iñaki
El vie., 5 mar. 2021 17:15, Subhomoy Ghosh escribió:
> Thanks, Iñaki! Your package gave me enough hints to create the following
> attempt which seemed to have worked.
>
> #include
>
>
Thanks, Iñaki! Your package gave me enough hints to create the following
attempt which seemed to have worked.
#include
using namespace Rcpp;
using namespace arma;
// [[Rcpp::depends(RcppArmadillo)]]
class Distribution {
public:
virtual Distribution* clone() {return (new Distribution(*this))
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
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. Th
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_) {}
~Uniform2()
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.
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 dis
On Thu, 4 Mar 2021 at 17:39, Subhomoy Ghosh wrote:
>
> 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 with a pointer on it and create an external pointer that can be
>