[Rcpp-devel] Problems wrapping stl::vector<int>

Dirk Eddelbuettel edd at debian.org
Fri Jan 3 18:19:55 CET 2014


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


More information about the Rcpp-devel mailing list