[Rcpp-devel] Enquire on Rcpp::wrap or equivilant
edd at debian.org
Sun Dec 5 20:33:29 CET 2010
On 5 December 2010 at 20:09, Tama Ma wrote:
| Dear Rcpp developers,
| May I kindly enquire on the wrapping of a portion of a container into an R
| numeric array by Rcpp::wrap?
| For example, I wish to have:
| template <class size_type, class element_type>
| ( element_type* obj
| , size_type* n
| Rcpp::NumericVector Rvec;
| std::copy( *obj , *(obj+n), std::back_inserter(Rvec));
| return Rvec;
| May I know how I can do this?
I don't follow. Rcpp::NumericVector is _not_ templated. It always uses
double; and Rcpp::IntegerVector uses int and so on.
So your 'convert' should not be a template function.
Next, because you stay NumericVector (or equivalent) there is no need to
reinvent wrap() as it already works.
But maybe I misunderstood. Also:
On 5 December 2010 at 19:57, Tama Ma wrote:
| I agree with you that for fast development, inline looks more attractive.
| Thank you for sharing!
You may want to glance at the list archives. There have been quite a few working
examples and gems posted.
Dirk Eddelbuettel | edd at debian.org | http://dirk.eddelbuettel.com
More information about the Rcpp-devel