[Rcpp-devel] Problems wrapping stl::vector<int>
Hadley Wickham
h.wickham at gmail.com
Fri Jan 3 18:42:22 CET 2014
Another solution is to rely on Rcpp's auto-wrapping smarts:
// [[Rcpp::export]]
std::vector<int> test(){
std::vector<int> a;
a.push_back(1);
a.push_back(2);
a.push_back(3);
return a;
}
Hadley
On Fri, Jan 3, 2014 at 11:19 AM, Dirk Eddelbuettel <edd at debian.org> wrote:
>
> Ale,
>
> Try this:
>
> R> sourceCpp("/tmp/scratchpad.cpp")
> R> test()
> [1] 1 2 3
> R>
>
> Using the file below.
>
> Dirk
>
> -----------------------------------------------------------------------------
>
> #include <Rcpp.h>
>
> using namespace Rcpp;
>
> // [[Rcpp::export]]
> IntegerVector test(){
> std::vector<int> a;
> a.push_back(1);
> a.push_back(2);
> a.push_back(3);
> return wrap(a);
> }
>
> -----------------------------------------------------------------------------
>
> --
> Dirk Eddelbuettel | edd at debian.org | http://dirk.eddelbuettel.com
> _______________________________________________
> Rcpp-devel mailing list
> Rcpp-devel at lists.r-forge.r-project.org
> https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel
--
http://had.co.nz/
More information about the Rcpp-devel
mailing list