[Rcpp-devel] Rcpp vector classes vs std::vector for custom class member variables

Jon Clayden jon.clayden at gmail.com
Tue Oct 8 15:34:48 CEST 2013


On 8 October 2013 14:19, Dirk Eddelbuettel <edd at debian.org> wrote:

>
> On 8 October 2013 at 13:53, Jon Clayden wrote:
> | I think I do... ;)  I need the object to hold state and not be
> deallocated
> | between calls into the C++ code. I also want to allow for the
> possibility that
> | multiple Foo objects exist, and are being operated on simultaneously. So
> | holding a handle on the R side and passing it back to each C++ function
> that
> | works with the object seems like the natural approach to me.
>
> A really simple way to do that is that create a container class that has
> this
> type as an object, and to create an init function, an accessor function,
> ...
>
> Rcpp modules can do that for you too just via declarations, resulting in
> Reference Class objects at the R level.  This is a little more advanced;
> maybe more suitable for your next project, or now if you are willing to
> read
> up (Rcpp modules vignette, corresponding chapter in the Rcpp book, existing
> packages, ...)
>

Right, thanks. I will read the modules vignette for a start.


> | Agreed, but it's a consideration. I fully accept that the choice depends
> on the
> | particular application, as you and Dirk both said. I was just wondering
> what
> | the baseline performance difference (if any) might be.
>
> Nobody knows ex ante. There is no explicit slowdown baked in. As we have
> suggested several times, you need to measure it!


Yes, OK - poor phrasing on my part. I take the point.

Jon
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20131008/fd3dd39e/attachment.html>


More information about the Rcpp-devel mailing list