[Rcpp-commits] r4018 - pkg/Rcpp/inst/include/Rcpp/vector

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Thu Nov 22 15:10:50 CET 2012


Author: romain
Date: 2012-11-22 15:10:49 +0100 (Thu, 22 Nov 2012)
New Revision: 4018

Modified:
   pkg/Rcpp/inst/include/Rcpp/vector/Vector.h
Log:
clean Vector<Interator> constructors

Modified: pkg/Rcpp/inst/include/Rcpp/vector/Vector.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/vector/Vector.h	2012-11-22 13:14:48 UTC (rev 4017)
+++ pkg/Rcpp/inst/include/Rcpp/vector/Vector.h	2012-11-22 14:10:49 UTC (rev 4018)
@@ -227,19 +227,29 @@
     
    
     template <typename InputIterator>
-    Vector( InputIterator first, InputIterator last) : RObject(){
-        assign( first, last ) ;
+    Vector( InputIterator first, InputIterator last) : RObject( ){
+        int n = std::distance(first, last) ;
+        RObject::setSEXP( Rf_allocVector(RTYPE, n) ) ;
+        std::copy( first, last, begin() ) ; 
     }
 
+    template <typename InputIterator>
+    Vector( InputIterator first, InputIterator last, int n) : RObject( ){
+        RObject::setSEXP( Rf_allocVector(RTYPE, n) ) ;
+        std::copy( first, last, begin() ) ; 
+    }
+
     template <typename InputIterator, typename Func>
     Vector( InputIterator first, InputIterator last, Func func) : 
-        RObject( Rf_allocVector( RTYPE, std::distance(first,last) ) )
+        RObject( )
     {
+        RObject::setSEXP( Rf_allocVector( RTYPE, std::distance(first,last) ) ) ;
         std::transform( first, last, begin(), func) ;
     }
     
     template <typename InputIterator, typename Func>
-    Vector( InputIterator first, InputIterator last, Func func, int n) : RObject( Rf_allocVector( RTYPE, n ) ){
+    Vector( InputIterator first, InputIterator last, Func func, int n) : RObject(  ){
+        RObject::setSEXP( Rf_allocVector( RTYPE, n ) ) ;
         std::transform( first, last, begin(), func) ;
     }
 



More information about the Rcpp-commits mailing list