[Rcpp-commits] r4028 - in pkg/Rcpp: . inst/include/Rcpp/vector

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Fri Nov 23 08:52:52 CET 2012


Author: romain
Date: 2012-11-23 08:52:52 +0100 (Fri, 23 Nov 2012)
New Revision: 4028

Modified:
   pkg/Rcpp/ChangeLog
   pkg/Rcpp/inst/include/Rcpp/vector/RangeIndexer.h
   pkg/Rcpp/inst/include/Rcpp/vector/Vector.h
Log:
RangeIndexer can be used for sugar now

Modified: pkg/Rcpp/ChangeLog
===================================================================
--- pkg/Rcpp/ChangeLog	2012-11-23 07:13:59 UTC (rev 4027)
+++ pkg/Rcpp/ChangeLog	2012-11-23 07:52:52 UTC (rev 4028)
@@ -2,6 +2,8 @@
 
         * src/AttributesParser.cpp : attempt to fix build issue on r-forge
         * include/Rcpp/DataFrame.h: nrows() method
+        * include/Rcpp/vector/RangeIndexer.h: now derives from VectorBase so that 
+        we can use it in sugar. 
 
 2012-11-22  JJ Allaire <jj at rstudio.org>
 

Modified: pkg/Rcpp/inst/include/Rcpp/vector/RangeIndexer.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/vector/RangeIndexer.h	2012-11-23 07:13:59 UTC (rev 4027)
+++ pkg/Rcpp/inst/include/Rcpp/vector/RangeIndexer.h	2012-11-23 07:52:52 UTC (rev 4028)
@@ -49,8 +49,8 @@
 
 namespace internal{
 
-template <int RTYPE, typename VECTOR>
-class RangeIndexer {
+template <int RTYPE, bool NA, typename VECTOR>
+class RangeIndexer : public VectorBase<RTYPE, NA, RangeIndexer<RTYPE,NA,VECTOR> >  {
 public:
 	typedef typename VECTOR::Proxy Proxy ;
 	typedef typename VECTOR::iterator iterator ;
@@ -60,36 +60,36 @@
 		start(vec_.begin() + range_.get_start() ), size_( range_.size() ) {}
 	
 		// TODO: size exceptions
-	template <bool NA, typename T>	
-	RangeIndexer& operator=( const Rcpp::VectorBase<RTYPE,NA,T>& x){
+	template <bool NA_, typename T>	
+	RangeIndexer& operator=( const Rcpp::VectorBase<RTYPE,NA_,T>& x){
 	    UNROLL_LOOP(=)
 	}
 	
-	template <bool NA, typename T>	
-	RangeIndexer& operator+=( const Rcpp::VectorBase<RTYPE,NA,T>& x){
+	template <bool NA_, typename T>	
+	RangeIndexer& operator+=( const Rcpp::VectorBase<RTYPE,NA_,T>& x){
 		 UNROLL_LOOP(+=)
 	}
 	
-	template <bool NA, typename T>	
-	RangeIndexer& operator*=( const Rcpp::VectorBase<RTYPE,NA,T>& x){
+	template <bool NA_, typename T>	
+	RangeIndexer& operator*=( const Rcpp::VectorBase<RTYPE,NA_,T>& x){
 		UNROLL_LOOP(*=)
 	}
 	
-	template <bool NA, typename T>	
-	RangeIndexer& operator-=( const Rcpp::VectorBase<RTYPE,NA,T>& x){
+	template <bool NA_, typename T>	
+	RangeIndexer& operator-=( const Rcpp::VectorBase<RTYPE,NA_,T>& x){
 		UNROLL_LOOP(-=)
 	}
 	
-	template <bool NA, typename T>	
-	RangeIndexer& operator/=( const Rcpp::VectorBase<RTYPE,NA,T>& x){
+	template <bool NA_, typename T>	
+	RangeIndexer& operator/=( const Rcpp::VectorBase<RTYPE,NA_,T>& x){
 		UNROLL_LOOP(/=)
 	}
 	
-	inline Proxy operator[]( int i ){
+	inline Proxy operator[]( int i ) const {
 	    return start[i] ;
 	}
 	
-	inline int size(){
+	inline int size() const {
 		return size_ ;
 	}
 	

Modified: pkg/Rcpp/inst/include/Rcpp/vector/Vector.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/vector/Vector.h	2012-11-23 07:13:59 UTC (rev 4027)
+++ pkg/Rcpp/inst/include/Rcpp/vector/Vector.h	2012-11-23 07:52:52 UTC (rev 4028)
@@ -663,7 +663,7 @@
 
 public:
 	
-    typedef internal::RangeIndexer<RTYPE,Vector> Indexer ;
+    typedef internal::RangeIndexer<RTYPE,true,Vector> Indexer ;
 	
     inline Indexer operator[]( const Range& range ){
         return Indexer( const_cast<Vector&>(*this), range );



More information about the Rcpp-commits mailing list