[Rcpp-commits] r1651 - in pkg/Rcpp/inst/include/Rcpp: internal traits vector

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Tue Jun 22 19:32:27 CEST 2010


Author: romain
Date: 2010-06-22 19:32:25 +0200 (Tue, 22 Jun 2010)
New Revision: 1651

Modified:
   pkg/Rcpp/inst/include/Rcpp/internal/wrap.h
   pkg/Rcpp/inst/include/Rcpp/traits/expands_to_logical.h
   pkg/Rcpp/inst/include/Rcpp/vector/VectorBase.h
Log:
better impl of expands_to_logical detection

Modified: pkg/Rcpp/inst/include/Rcpp/internal/wrap.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/internal/wrap.h	2010-06-21 17:34:09 UTC (rev 1650)
+++ pkg/Rcpp/inst/include/Rcpp/internal/wrap.h	2010-06-22 17:32:25 UTC (rev 1651)
@@ -424,7 +424,8 @@
  */
 template <typename T>
 SEXP wrap_dispatch_unknown_iterable(const T& object, ::Rcpp::traits::true_type){
-	return wrap_dispatch_unknown_iterable__logical( object, typename ::Rcpp::traits::expands_to_logical<T>::type() ) ;
+	return wrap_dispatch_unknown_iterable__logical( object, 
+		typename ::Rcpp::traits::expands_to_logical<T>::type() ) ;
 }
 
 template <typename T, typename elem_type>

Modified: pkg/Rcpp/inst/include/Rcpp/traits/expands_to_logical.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/traits/expands_to_logical.h	2010-06-21 17:34:09 UTC (rev 1650)
+++ pkg/Rcpp/inst/include/Rcpp/traits/expands_to_logical.h	2010-06-22 17:32:25 UTC (rev 1651)
@@ -29,12 +29,20 @@
 namespace Rcpp{
 namespace traits{
 
-  template<typename T>
-  class _has_rtype_helper : __sfinae_types {
+	template <int RTYPE>
+	struct expands_to_logical__impl{} ;
+	
+	template <>
+	struct expands_to_logical__impl<LGLSXP> {
+		struct r_expands_to_logical{}; 
+	} ;
+
+	template<typename T>
+	class _has_rtype_helper : __sfinae_types {
       template<typename U> struct _Wrap_type { };
 
       template<typename U>
-        static __one __test(_Wrap_type<typename U::r_type>*);
+        static __one __test(_Wrap_type<typename U::r_expands_to_logical>*);
 
       template<typename U>
         static __two __test(...);
@@ -42,9 +50,9 @@
     public:
       static const bool value = sizeof(__test<T>(0)) == 1;
     };
-		
+  
   template<typename T> struct expands_to_logical : 
-  	integral_constant<bool,_has_rtype_helper<T>::value & T::r_type::value == LGLSXP > { };
+  	integral_constant<bool, _has_rtype_helper<T>::value >{ };
     
     
 } 

Modified: pkg/Rcpp/inst/include/Rcpp/vector/VectorBase.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/vector/VectorBase.h	2010-06-21 17:34:09 UTC (rev 1650)
+++ pkg/Rcpp/inst/include/Rcpp/vector/VectorBase.h	2010-06-22 17:32:25 UTC (rev 1651)
@@ -23,12 +23,10 @@
 #define Rcpp__vector__VectorBase_h
 
 namespace Rcpp{
-
-
 	
 /** a base class for vectors, modelled after the CRTP */
 template <int RTYPE, bool na, typename VECTOR>
-class VectorBase {
+class VectorBase : public traits::expands_to_logical__impl<RTYPE> {
 public:
 	struct r_type : traits::integral_constant<int,RTYPE>{} ;
 	struct can_have_na : traits::integral_constant<bool,na>{} ;



More information about the Rcpp-commits mailing list