Skip to content
Prev 2412 / 10988 Next

[Rcpp-devel] Create an instance of a reference class for a C++ class exported as a module from within C++?

To elaborate a bit:

Am I off-base in thinking you can make a custom constructor for your
class that calls R's new(), being careful to avoid circularity, that
returns a blank instance to your method to be filled? Is something
like the following anywhere near this?

class MyClass {
  public:
    Bar(bool x_) : {}  // for spawn
    Bar() : {}

  private:
    Bar spawn() {
      Environment meth("package:methods");
      Function Rnew = meth["new"];
      Rcpp::XPtr<MyClass> NewObj( Rnew(false) );
    }
};

-Christian