Re: [Rcpp-devel] Ease passing pointers

2013-12-31 Thread Tim Keitt
On Tue, Dec 31, 2013 at 3:55 PM, Dirk Eddelbuettel wrote: > > On 31 December 2013 at 15:27, Tim Keitt wrote: > | A little obscure indeed. I got a little lost in the documentation and was > | looking for a shortcut. I think I need to specialize "wrap" and "as". > > Yes, many adaptations to local d

Re: [Rcpp-devel] Ease passing pointers

2013-12-31 Thread Dirk Eddelbuettel
On 31 December 2013 at 15:27, Tim Keitt wrote: | A little obscure indeed. I got a little lost in the documentation and was | looking for a shortcut. I think I need to specialize "wrap" and "as". Yes, many adaptations to local data structures need that. There are a few example posts, eg on the Rcp

Re: [Rcpp-devel] Ease passing pointers

2013-12-31 Thread Tim Keitt
On Tue, Dec 31, 2013 at 3:10 PM, Dirk Eddelbuettel wrote: > > On 31 December 2013 at 14:16, Tim Keitt wrote: > | Can the following be simplified? > | > | (Typed in email, so not live code.) > | > | // [[Rcpp::export]] > | void func(SEXP x) > | { > | XPtr y(x); > | func2(&*y); > | y->memfunc

Re: [Rcpp-devel] Ease passing pointers

2013-12-31 Thread Dirk Eddelbuettel
On 31 December 2013 at 14:16, Tim Keitt wrote: | Can the following be simplified? | | (Typed in email, so not live code.) | | // [[Rcpp::export]] | void func(SEXP x) | { |   XPtr y(x); |   func2(&*y); |   y->memfunc(); | } | | Is there a way to avoid the need to construct the XPtr in the 1st li

[Rcpp-devel] Ease passing pointers

2013-12-31 Thread Tim Keitt
Can the following be simplified? (Typed in email, so not live code.) // [[Rcpp::export]] void func(SEXP x) { XPtr y(x); func2(&*y); y->memfunc(); } Is there a way to avoid the need to construct the XPtr in the 1st line? Hoping for: // [[Rcpp::export]] void func(aType* x) { func2(x); x

Re: [Rcpp-devel] exporting void test(void) function

2013-12-31 Thread Tim Keitt
On Tue, Dec 31, 2013 at 1:45 PM, JJ Allaire wrote: > Am I correct in noting that >> >> // [[Rcpp::export]] >> void test(void) >> { >> // do something >> } >> >> does not generate any code in RcppExports.R? >> > > The problem occurs because the attributes parser doesn't know what to do > with

Re: [Rcpp-devel] exporting void test(void) function

2013-12-31 Thread JJ Allaire
> > Am I correct in noting that > > // [[Rcpp::export]] > void test(void) > { > // do something > } > > does not generate any code in RcppExports.R? > The problem occurs because the attributes parser doesn't know what to do with the void argument specification. If you declare the function with

Re: [Rcpp-devel] Example of using finalizer with Rcpp::XPtr

2013-12-31 Thread Tim Keitt
On Mon, Dec 30, 2013 at 10:18 PM, Tim Keitt wrote: > Does anyone have an example of how to override the default delete > finalizer when using the XPtr template? > > I tried a functor, but that does not match the template signature, at > least in my attempt. > I decided to disable the default del

Re: [Rcpp-devel] exporting void test(void) function

2013-12-31 Thread Tim Keitt
On Mon, Dec 30, 2013 at 10:36 PM, Dirk Eddelbuettel wrote: > > Hi Tim, > > Nice to see you here! > Nice to be here. Happy new year! > > On 30 December 2013 at 22:15, Tim Keitt wrote: > | Apologies if this is the wrong list for user questions -- happy to be > | redirected -- I did not see it im

Re: [Rcpp-devel] What is the most efficient method to check if a Rcpp vector contains an element?

2013-12-31 Thread Romain Francois
Thanks. In any case, for things like this the best thing to do is to not trust what anyone says and actually benchmark with realistic data. Romain Le 31 déc. 2013 à 16:29, Hadley Wickham a écrit : >> I believe you are mistaken. sorting is an expensive O( N log(N) ) operation. >> >> I’d use

Re: [Rcpp-devel] What is the most efficient method to check if a Rcpp vector contains an element?

2013-12-31 Thread Hadley Wickham
> I believe you are mistaken. sorting is an expensive O( N log(N) ) operation. > > I’d use something like std::find (or std::any_of if you use C++11). Those > are O(N) > Otherwise, you might like Rcpp::any or Rcpp::any_of It depends on the scenario - if you want to look up M values in a vector of

Re: [Rcpp-devel] calling a homegrown cpp function from my own package when using sourceCpp

2013-12-31 Thread Hadley Wickham
> I am reluctant to follow Romains suggestion because the package has a lot of > c-code in it, so using load_all() takes quite some time because all c and c++ > code is being compiled. (Maybe that is just slow on windows? I tried on linux > (ubuntu) too but I can't get devtools installed (becaus

Re: [Rcpp-devel] exporting void test(void) function

2013-12-31 Thread Romain Francois
Hello, This is fixed in Rcpp implementations I maintain: Rcpp11 and Rcpp98 and tested for in Rcpp-test. https://github.com/romainfrancois/Rcpp11/blob/master/src/attributes.cpp#L1195 https://github.com/romainfrancois/Rcpp98/blob/master/src/attributes.cpp#L1228 Trivial to port the fix to Rcpp.