[Rcpp-devel] Possible inconsistency in Rcpp vs stl in erase(iterator, iterator)

Dirk Eddelbuettel edd at debian.org
Wed Jun 5 18:22:16 CEST 2013


On 5 June 2013 at 16:32, Romain Francois wrote:
| This is now fixed in rev 4330.

Make it rev 4332 which now does the right thing:

R> sourceCpp("/tmp/toni.cpp")

R> truncateTest()
  STL Rcpp
1   1    1
2   2    2
3   3    3
4   4    4
5   5    5
R> 

Dirk

PS Once-more modified 'tony.cpp' below

#include <Rcpp.h>

// [[Rcpp::export]]
Rcpp::DataFrame truncateTest() {

  Rcpp::NumericVector 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());
  l.erase(l.begin()+5,l.end());

  return(Rcpp::DataFrame::create(Rcpp::Named("STL")=v, 
				 Rcpp::Named("Rcpp")=l));
}

/*** R
truncateTest()
*/


-- 
Dirk Eddelbuettel | edd at debian.org | http://dirk.eddelbuettel.com


More information about the Rcpp-devel mailing list