Thanks. I'll have a look.
Le 05/06/13 14:09, Toni Giorgino a écrit :
Dears,
I am a newbie to Rcpp. I may have found an off-by-one inconsistency in
the handling of List::erase(iter1,iter2) operation with respect to its
homologous in the STL (which I suppose is intended to mimic). In STL,
iter2 can be the container's .end(); in Rcpp, the same gives an out of
boundary error. (See below)
Thanks for the incredible package. Best
Test case...
#include <Rcpp.h>
#include <iostream>
// [[Rcpp::export]]
SEXP truncateTest() {
BEGIN_RCPP
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;
END_RCPP
}
/*** R
# library(Rcpp)
# sourceCpp("truncateTest.cpp")
# truncateTest()
# #prints 6 and 5
*/
--
Romain Francois
Professional R Enthusiast
+33(0) 6 28 91 30 30
R Graph Gallery: http://gallery.r-enthusiasts.com
blog: http://blog.r-enthusiasts.com
|- http://bit.ly/Zs97qg : highlight 0.4.1
`- http://bit.ly/10X94UM : Mobile version of the graph gallery
_______________________________________________
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