From soeren.vogel at uzh.ch  Fri May 13 16:19:16 2011
From: soeren.vogel at uzh.ch (soeren.vogel at uzh.ch)
Date: Fri, 13 May 2011 16:19:16 +0200
Subject: [Rd] Create and access several instances of a C++ class from R
In-Reply-To: <4DC50DB9.8090300@r-enthusiasts.com>
References: <49517500-0069-4F75-81E5-DAFFA2F53C08@uzh.ch>	<19908.38110.411719.560626@max.nulle.part>
	<E7B857D5-FA61-4215-838F-88F79CACADD6@uzh.ch>
	<4DC50DB9.8090300@r-enthusiasts.com>
Message-ID: <0A8C949C-0865-4C34-AB12-1F8CE5ECB8F7@uzh.ch>

On 07.05.2011, at 11:15, Romain Francois wrote:

> Try having do_bar with this signature:
> 
> void do_bar(NumericVector data);
> 
> And my advice would probably also to have your C field either as a NumericVector. NumericVector is just a thin wrapper around the internal R data structure.
> 
> Having data members as direct pointers is dangerous and not a very C++ way of doing things.
> 
> If you want to learn about the STL, there are many books that cover it and plenty of online resources. I use this : http://cplusplus.com/reference/stl/. Using the STL is easier than dealing with pointers and stuff.
> 
> If your game is to pass down a double* to some api you use, you can use the begin method of NumericVector, this will give you the array pointer (as would REAL do on the underlying SEXP):

[...]

For the files: the discussion continues here:

http://lists.r-forge.r-project.org/pipermail/rcpp-devel/2011-May/002261.html

Regards
S?ren



[Rd] Create and access several instances of a C++ class from R
soeren.vogel at uzh.ch