[Rcpp-commits] r4332 - pkg/Rcpp/inst/include/Rcpp/api/meat
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Wed Jun 5 17:11:02 CEST 2013
Author: romain
Date: 2013-06-05 17:11:01 +0200 (Wed, 05 Jun 2013)
New Revision: 4332
Modified:
pkg/Rcpp/inst/include/Rcpp/api/meat/Vector.h
Log:
fixed bounds checks
Modified: pkg/Rcpp/inst/include/Rcpp/api/meat/Vector.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/api/meat/Vector.h 2013-06-05 14:29:24 UTC (rev 4331)
+++ pkg/Rcpp/inst/include/Rcpp/api/meat/Vector.h 2013-06-05 15:11:01 UTC (rev 4332)
@@ -239,7 +239,7 @@
template <int RTYPE>
typename Vector<RTYPE>::iterator Vector<RTYPE>::erase_single__impl( iterator position ){
- if( position < begin() || position >= end() ) throw index_out_of_bounds( ) ;
+ if( position < begin() || position > end() ) throw index_out_of_bounds( ) ;
int n = size() ;
Vector target( n - 1 ) ;
iterator target_it(target.begin()) ;
@@ -281,7 +281,7 @@
template <int RTYPE>
typename Vector<RTYPE>::iterator Vector<RTYPE>::erase_range__impl( iterator first, iterator last ){
if( first > last ) throw std::range_error("invalid range") ;
- if( last >= end() || first < begin() ) throw index_out_of_bounds() ;
+ if( last > end() || first < begin() ) throw index_out_of_bounds() ;
iterator it = begin() ;
iterator this_end = end() ;
@@ -296,7 +296,7 @@
for( ; it < first; ++it, ++target_it ){
*target_it = *it ;
}
- result = it ;
+ result = target_it +1 ;
for( it = last ; it < this_end; ++it, ++target_it ){
*target_it = *it ;
}
@@ -307,7 +307,7 @@
*target_it = *it ;
SET_STRING_ELT( newnames, i, STRING_ELT(names, i ) );
}
- result = it ;
+ result = target_it + 1 ;
for( it = last ; it < this_end; ++it, ++target_it, i++ ){
*target_it = *it ;
SET_STRING_ELT( newnames, i, STRING_ELT(names, i + nremoved ) );
More information about the Rcpp-commits
mailing list