[Rcpp-devel] Feature request: const_iterators

schattenpflanze at arcor.de schattenpflanze at arcor.de
Mon Apr 11 12:30:10 CEST 2011


Hello,

I have a suggestion for an additional feature of Rcpp. It would be nice 
to have const_iterators besides mutable iterators for 
Rcpp::NumericVector (and other vectors and matrices). This would make it 
easier to use templated functions like the one below, which can be used 
with std::vectors _and_ Rcpp::NumericVectors:

template <typename Vector>
void foo(const Vector& v) {
  typename Vector::const_iterator v_it=v.begin(), v_end=v.end();
  for (; v_it!=v_end; ++v_it) {
    // do amazing stuff
  }
}

Best regards,
Peter


More information about the Rcpp-devel mailing list