[Rcpp-commits] r1661 - in pkg/Rcpp/inst: doc/Rcpp-sugar include/Rcpp/sugar/functions

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed Jun 23 11:28:11 CEST 2010


Author: romain
Date: 2010-06-23 11:28:11 +0200 (Wed, 23 Jun 2010)
New Revision: 1661

Modified:
   pkg/Rcpp/inst/doc/Rcpp-sugar/Rcpp-sugar.Rnw
   pkg/Rcpp/inst/include/Rcpp/sugar/functions/sapply.h
Log:
slightly nicer impl of sapply

Modified: pkg/Rcpp/inst/doc/Rcpp-sugar/Rcpp-sugar.Rnw
===================================================================
--- pkg/Rcpp/inst/doc/Rcpp-sugar/Rcpp-sugar.Rnw	2010-06-23 09:02:54 UTC (rev 1660)
+++ pkg/Rcpp/inst/doc/Rcpp-sugar/Rcpp-sugar.Rnw	2010-06-23 09:28:11 UTC (rev 1661)
@@ -487,11 +487,11 @@
 	Sapply<RTYPE,NA,T,Function>
 > {
 public:
-	const static int RESULT_R_TYPE = Rcpp::traits::r_sexptype_traits<
-		typename ::Rcpp::traits::result_of<Function>::type 
-		>::rtype ;
+	typedef typename ::Rcpp::traits::result_of<Function>::type  ;
+	const static int RESULT_R_TYPE = 
+		Rcpp::traits::r_sexptype_traits<result_type>::rtype ;
+	
 	typedef Rcpp::VectorBase<RTYPE,NA,T> VEC ;
-	typedef typename ::Rcpp::traits::result_of<Function>::type result_type ;
 	typedef typename Rcpp::traits::r_vector_element_converter<RESULT_R_TYPE>::type converter_type ;
 	typedef typename Rcpp::traits::storage_type<RESULT_R_TYPE>::type STORAGE ;
 	
@@ -537,7 +537,7 @@
 template. 
 
 <<lang=cpp>>=
-	typename ::Rcpp::traits::result_of<Function>::type 
+typedef typename ::Rcpp::traits::result_of<Function>::type result_type ;
 @
 
 The \texttt{result\_of} type trait is implemented as such: 
@@ -554,8 +554,23 @@
 } ;
 @
 
+The generic definition of \texttt{result\_of} targets functors 
+with a nested \texttt{result\_type} type. 
 
+The second definition is a partial specialization targetting 
+function pointers.
 
+\subsubsection{Indentification of expression type}
+
+Based on the result type of the function, the \texttt{r\_sexptype\_traits}
+trait is used to identify the expression type. 
+
+<<lang=cpp>>=
+const static int RESULT_R_TYPE = Rcpp::traits::r_sexptype_traits<
+    typename ::Rcpp::traits::result_of<Function>::type 
+>::rtype ;
+@
+
 \bibliographystyle{abbrvnat}
 \bibliography{Rcpp}
 

Modified: pkg/Rcpp/inst/include/Rcpp/sugar/functions/sapply.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/sugar/functions/sapply.h	2010-06-23 09:02:54 UTC (rev 1660)
+++ pkg/Rcpp/inst/include/Rcpp/sugar/functions/sapply.h	2010-06-23 09:28:11 UTC (rev 1661)
@@ -34,11 +34,11 @@
 	Sapply<RTYPE,NA,T,Function>
 > {
 public:
-	const static int RESULT_R_TYPE = Rcpp::traits::r_sexptype_traits<
-		typename ::Rcpp::traits::result_of<Function>::type 
-		>::rtype ;
+	typedef typename ::Rcpp::traits::result_of<Function>::type result_type ;
+	const static int RESULT_R_TYPE = 
+		Rcpp::traits::r_sexptype_traits<result_type>::rtype ;
+	
 	typedef Rcpp::VectorBase<RTYPE,NA,T> VEC ;
-	typedef typename ::Rcpp::traits::result_of<Function>::type result_type ;
 	typedef typename Rcpp::traits::r_vector_element_converter<RESULT_R_TYPE>::type converter_type ;
 	typedef typename Rcpp::traits::storage_type<RESULT_R_TYPE>::type STORAGE ;
 	



More information about the Rcpp-commits mailing list