[Rcpp-devel] Module with out default constructor.

Andrew Redd amredd at gmail.com
Thu Oct 28 16:33:56 CEST 2010


Thanks,
I'm taking the approach of the default constructor with an initializer
function.  That seems to be a reasonable workaround.

Oh and BTW I was not using Notepad++ for some reason I was not able to copy
and paste from vim into chrome.  Notepad++ does great indenting although not
quite as good as vim.  I'm right now developing on Ubuntu, since CUDA works
much easier on it.

-Andrew

On Wed, Oct 27, 2010 at 7:36 PM, Romain Francois
<romain at r-enthusiasts.com>wrote:

> Le 27/10/10 12:32, Andrew Redd a écrit :
>
>  Is it possible with Rcpp Modules to have a class that does not have a
>> default constructor?  Consider this example
>> -----
>> #include <R.h>
>> #include <Rcpp.h>
>> class c1{
>> private:
>> int n;
>> int * x;
>> c1();
>> public:
>> c1(int n):n(n){}
>> int getn(){return n;}
>> };
>> RCPP_MODULE(c1){
>> using namespace Rcpp;
>> class_<c1>("c1")
>> .property("n",&c1::getn)
>> ;
>> }
>> -----
>> Here I have a class that I do not want to allow to initialize without
>> specifying n.  Yes it does not do anything but the question is related
>> to a class where constructors and destructors allocate and free special
>> memory.   And Yes I know that this fails on compile since c1() is
>> private. Can Rcpp handle this kind of setup?  If not suggestions about
>> workarounds?
>>
>> thanks,
>> Andrew
>>
>
> At the moment, classes that are exposed through Rcpp modules require
> default constructors.
>
> We need to take some inspiration from boost.python again to allow other
> constructors. e.g.
> http://www.boost.org/doc/libs/1_44_0/libs/python/doc/tutorial/doc/html/python/exposing.html#python.constructors
>
> This has been on our list for some time now. Not sure when we will have
> this. Additional resources are welcome.
>
> Romain
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20101028/b0e90e66/attachment.htm>


More information about the Rcpp-devel mailing list