Thanks,<div>I'm taking the approach of the default constructor with an initializer function. That seems to be a reasonable workaround.</div><div><br></div><div>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.</div>
<div><br></div><div>-Andrew<br><br><div class="gmail_quote">On Wed, Oct 27, 2010 at 7:36 PM, Romain Francois <span dir="ltr"><<a href="mailto:romain@r-enthusiasts.com">romain@r-enthusiasts.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">Le 27/10/10 12:32, Andrew Redd a écrit :<div><div></div><div class="h5"><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Is it possible with Rcpp Modules to have a class that does not have a<br>
default constructor? Consider this example<br>
-----<br>
#include <R.h><br>
#include <Rcpp.h><br>
class c1{<br>
private:<br>
int n;<br>
int * x;<br>
c1();<br>
public:<br>
c1(int n):n(n){}<br>
int getn(){return n;}<br>
};<br>
RCPP_MODULE(c1){<br>
using namespace Rcpp;<br>
class_<c1>("c1")<br>
.property("n",&c1::getn)<br>
;<br>
}<br>
-----<br>
Here I have a class that I do not want to allow to initialize without<br>
specifying n. Yes it does not do anything but the question is related<br>
to a class where constructors and destructors allocate and free special<br>
memory. And Yes I know that this fails on compile since c1() is<br>
private. Can Rcpp handle this kind of setup? If not suggestions about<br>
workarounds?<br>
<br>
thanks,<br>
Andrew<br>
</blockquote>
<br></div></div>
At the moment, classes that are exposed through Rcpp modules require default constructors.<br>
<br>
We need to take some inspiration from boost.python again to allow other constructors. e.g. <a href="http://www.boost.org/doc/libs/1_44_0/libs/python/doc/tutorial/doc/html/python/exposing.html#python.constructors" target="_blank">http://www.boost.org/doc/libs/1_44_0/libs/python/doc/tutorial/doc/html/python/exposing.html#python.constructors</a><br>
<br>
This has been on our list for some time now. Not sure when we will have this. Additional resources are welcome.<br><font color="#888888">
<br>
Romain<br>
<br>
</font></blockquote></div><br></div>