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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sun Sep 15 22:18:34 CEST 2013


Author: edd
Date: 2013-09-15 22:18:34 +0200 (Sun, 15 Sep 2013)
New Revision: 4489

Modified:
   pkg/Rcpp/ChangeLog
   pkg/Rcpp/inst/include/Rcpp/InputParameter.h
Log:
Add 'const' case to complement 'plain', 'reference' and 'const reference'


Modified: pkg/Rcpp/ChangeLog
===================================================================
--- pkg/Rcpp/ChangeLog	2013-09-15 19:42:23 UTC (rev 4488)
+++ pkg/Rcpp/ChangeLog	2013-09-15 20:18:34 UTC (rev 4489)
@@ -1,5 +1,7 @@
 2013-09-15  Dirk Eddelbuettel  <edd at debian.org>
 
+	* inst/include/Rcpp/InputParameter.h (Rcpp): Add 'const' case
+
 	* inst/unitTests/cpp/Vector.cpp: New unit tests for std::vector
 	conversions, using both int and double arguments
 	* inst/unitTests/runit.Vector.R: R complement of these tests

Modified: pkg/Rcpp/inst/include/Rcpp/InputParameter.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/InputParameter.h	2013-09-15 19:42:23 UTC (rev 4488)
+++ pkg/Rcpp/inst/include/Rcpp/InputParameter.h	2013-09-15 20:18:34 UTC (rev 4489)
@@ -50,6 +50,19 @@
     private:
         T obj ;
     } ;
+
+    // same for const
+    template <typename T>
+    class ConstInputParameter {
+    public:
+        typedef const T const_nonref ;
+        ConstInputParameter(SEXP x_) : obj( as<T>(x_) ){}
+        
+        inline operator const_nonref() { return obj ; }
+        
+    private:
+        T obj ;
+    } ;
     
     // same for const references
     template <typename T>
@@ -74,6 +87,10 @@
             typedef typename Rcpp::ReferenceInputParameter<T> type ;
         } ;
         template <typename T>
+        struct input_parameter<const T> {
+            typedef typename Rcpp::ConstInputParameter<T> type ;
+        } ;
+        template <typename T>
         struct input_parameter<const T&> {
             typedef typename Rcpp::ConstReferenceInputParameter<T> type ;
         } ;



More information about the Rcpp-commits mailing list