Hi Toni,
Nice example -- we'll take a look. Probably a buglet at our end. The STL are just for convenience: each operation requires _a full copy_ underneath (as we work on R memory) so they are hogs, which is why nobody may have found this bug yet. Two minor comments: The BEGIN and END macros get autoinserted, you probably want a return value, and the R code at the bottom get run when you call it: R> sourceCpp("/tmp/toni.cpp") R> truncateTest() std::vector left with 6 Rcpp::List left with 5 NULL R> ##prints 6 and 5 R> With that, a minor improvement to your code: #include <Rcpp.h> #include <iostream> // [[Rcpp::export]] SEXP truncateTest() { using namespace std; Rcpp::List l; std::vector<int> v; for (int i=1; i<=10; i++) { v.push_back(i); l.push_back(i); } v.erase(v.begin()+5,v.end()-1); l.erase(l.begin()+5,l.end()-1); // ? cout << "std::vector left with " << v.size() << endl; cout << "Rcpp::List left with " << l.size() << endl; return R_NilValue; } /*** R truncateTest() ##prints 6 and 5 */ We'll check end(). Dirk -- Dirk Eddelbuettel | e...@debian.org | http://dirk.eddelbuettel.com _______________________________________________ Rcpp-devel mailing list Rcpp-devel@lists.r-forge.r-project.org https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel