[Rcpp-commits] r1646 - pkg/Rcpp/inst/include/Rcpp/sugar/logical

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Mon Jun 21 14:57:18 CEST 2010


Author: romain
Date: 2010-06-21 14:57:18 +0200 (Mon, 21 Jun 2010)
New Revision: 1646

Modified:
   pkg/Rcpp/inst/include/Rcpp/sugar/logical/and.h
   pkg/Rcpp/inst/include/Rcpp/sugar/logical/or.h
Log:
 (SingleLogicalResult) || bool

Modified: pkg/Rcpp/inst/include/Rcpp/sugar/logical/and.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/sugar/logical/and.h	2010-06-21 12:55:23 UTC (rev 1645)
+++ pkg/Rcpp/inst/include/Rcpp/sugar/logical/and.h	2010-06-21 12:57:18 UTC (rev 1646)
@@ -212,7 +212,7 @@
 }
 
 template <bool LHS_NA, typename LHS_T>
-inline Rcpp::sugar::And_SingleLogicalResult_SingleLogicalResult<LHS_NA,LHS_T>
+inline Rcpp::sugar::And_SingleLogicalResult_bool<LHS_NA,LHS_T>
 operator&&( 
 	const Rcpp::sugar::SingleLogicalResult<LHS_NA,LHS_T>& lhs, 
 	bool rhs
@@ -221,7 +221,7 @@
 }
 
 template <bool LHS_NA, typename LHS_T>
-inline Rcpp::sugar::And_SingleLogicalResult_SingleLogicalResult<LHS_NA,LHS_T>
+inline Rcpp::sugar::And_SingleLogicalResult_bool<LHS_NA,LHS_T>
 operator&&( 
 	bool rhs, 
 	const Rcpp::sugar::SingleLogicalResult<LHS_NA,LHS_T>& lhs

Modified: pkg/Rcpp/inst/include/Rcpp/sugar/logical/or.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/sugar/logical/or.h	2010-06-21 12:55:23 UTC (rev 1645)
+++ pkg/Rcpp/inst/include/Rcpp/sugar/logical/or.h	2010-06-21 12:57:18 UTC (rev 1646)
@@ -165,6 +165,38 @@
 	
 } ;
 
+
+template <bool LHS_NA, typename LHS_T>
+class Or_SingleLogicalResult_bool : 
+public SingleLogicalResult< 
+	LHS_NA , 
+	And_SingleLogicalResult_bool<LHS_NA,LHS_T>
+	>
+{
+public: 
+	typedef SingleLogicalResult<LHS_NA,LHS_T> LHS_TYPE ;
+	typedef SingleLogicalResult< 
+		LHS_NA , 
+		And_SingleLogicalResult_bool<LHS_NA,LHS_T>
+	> BASE ;
+	
+	And_SingleLogicalResult_bool( const LHS_TYPE& lhs_, bool rhs_) :
+		lhs(lhs_), rhs(rhs_){} ;
+	
+	inline void apply(){
+		if( rhs ){
+			BASE::set( TRUE ) ;
+		} else{
+			BASE::set( lhs.get() ) ;
+		}
+	}
+		
+private:
+	const LHS_TYPE& lhs ;
+	bool rhs ;
+	
+} ;
+
 }
 }
 
@@ -176,6 +208,23 @@
 ){
 	return Rcpp::sugar::Or_SingleLogicalResult_SingleLogicalResult<LHS_NA,LHS_T,RHS_NA,RHS_T>( lhs, rhs ) ;
 }
+ 
+template <bool LHS_NA, typename LHS_T>
+inline Rcpp::sugar::Or_SingleLogicalResult_bool<LHS_NA,LHS_T>
+operator||( 
+	const Rcpp::sugar::SingleLogicalResult<LHS_NA,LHS_T>& lhs, 
+	bool rhs
+){
+	return Rcpp::sugar::Or_SingleLogicalResult_bool<LHS_NA,LHS_T>( lhs, rhs ) ;
+}
 
+template <bool LHS_NA, typename LHS_T>
+inline Rcpp::sugar::Or_SingleLogicalResult_bool<LHS_NA,LHS_T>
+operator||( 
+	bool rhs, 
+	const Rcpp::sugar::SingleLogicalResult<LHS_NA,LHS_T>& lhs
+){
+	return Rcpp::sugar::Or_SingleLogicalResult_bool<LHS_NA,LHS_T>( lhs, rhs ) ;
+}
 
 #endif



More information about the Rcpp-commits mailing list