[Rcpp-commits] r2031 - pkg/Rcpp/inst/include/Rcpp/vector
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Mon Aug 16 14:45:16 CEST 2010
Author: romain
Date: 2010-08-16 14:45:16 +0200 (Mon, 16 Aug 2010)
New Revision: 2031
Modified:
pkg/Rcpp/inst/include/Rcpp/vector/Vector.h
pkg/Rcpp/inst/include/Rcpp/vector/VectorBase.h
Log:
Modified: pkg/Rcpp/inst/include/Rcpp/vector/Vector.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/vector/Vector.h 2010-08-16 12:20:36 UTC (rev 2030)
+++ pkg/Rcpp/inst/include/Rcpp/vector/Vector.h 2010-08-16 12:45:16 UTC (rev 2031)
@@ -97,8 +97,9 @@
template <bool NA, typename VEC>
void import_expression( const VectorBase<RTYPE,NA,VEC>& other, int n ){
iterator start = begin() ;
- for( int i=0; i<n; i++, ++start){
- *start = other[i] ;
+ const VEC& ref = other.get_ref() ;
+ for( int i=0; i<n; i++, ++start){
+ *start = ref[i] ;
}
}
Modified: pkg/Rcpp/inst/include/Rcpp/vector/VectorBase.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/vector/VectorBase.h 2010-08-16 12:20:36 UTC (rev 2030)
+++ pkg/Rcpp/inst/include/Rcpp/vector/VectorBase.h 2010-08-16 12:45:16 UTC (rev 2031)
@@ -35,6 +35,10 @@
VECTOR& get_ref(){
return static_cast<VECTOR&>(*this) ;
}
+
+ const VECTOR& get_ref() const {
+ return static_cast<const VECTOR&>(*this) ;
+ }
inline stored_type operator[]( int i) const {
return static_cast<const VECTOR*>(this)->operator[](i) ;
More information about the Rcpp-commits
mailing list