[Rcpp-commits] r672 - pkg/src/Rcpp

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sun Feb 14 13:53:53 CET 2010


Author: romain
Date: 2010-02-14 13:53:52 +0100 (Sun, 14 Feb 2010)
New Revision: 672

Modified:
   pkg/src/Rcpp/Language.h
Log:
allow specification of the output type as a template parameter of unary_call (default to SEXP), using implicit as

Modified: pkg/src/Rcpp/Language.h
===================================================================
--- pkg/src/Rcpp/Language.h	2010-02-14 12:28:13 UTC (rev 671)
+++ pkg/src/Rcpp/Language.h	2010-02-14 12:53:52 UTC (rev 672)
@@ -167,15 +167,15 @@
 
 };
 
-template <typename T>
+template <typename T, typename OUT = SEXP>
 class unary_call : public std::unary_function<T,SEXP> {
 public:
 	unary_call( Language call_ ) : call(call_), proxy(call,1) {}
 	unary_call( Language call_, int index ) : call(call_), proxy(call_,index){}
 	
-	SEXP operator()( const T& object ){
+	OUT operator()( const T& object ){
 		proxy = object ;
-		return call.eval() ;
+		return as<OUT>( call.eval() ) ;
 	}
 	
 private:



More information about the Rcpp-commits mailing list