[Rcpp-commits] r1305 - pkg/Rcpp/inst/include/Rcpp

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Mon May 24 22:23:23 CEST 2010


Author: dmbates
Date: 2010-05-24 22:23:23 +0200 (Mon, 24 May 2010)
New Revision: 1305

Modified:
   pkg/Rcpp/inst/include/Rcpp/clone.h
Log:
Use a const_cast to allow clone to be applied to a const reference.


Modified: pkg/Rcpp/inst/include/Rcpp/clone.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/clone.h	2010-05-24 20:16:16 UTC (rev 1304)
+++ pkg/Rcpp/inst/include/Rcpp/clone.h	2010-05-24 20:23:23 UTC (rev 1305)
@@ -30,13 +30,15 @@
    - T can be converted to SEXP 
    - T has a SEXP constructor
 */
-template <typename T> T clone(T object) {
-	SEXP x = object ;
-	return T( Rf_duplicate( x ) ) ; 
+template <typename T> T clone(const T& object) {
+    SEXP x = const_cast<T&>(object) ;
+    return T( Rf_duplicate( x ) ) ; 
 }
+#if 0
 template<> inline SEXP clone(SEXP object){
-	return ::Rf_duplicate( object ) ;
+    return ::Rf_duplicate( object ) ;
 }
+#endif
 
 } // namespace Rcpp
 



More information about the Rcpp-commits mailing list