[Rcpp-commits] r1645 - 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:55:23 CEST 2010


Author: romain
Date: 2010-06-21 14:55:23 +0200 (Mon, 21 Jun 2010)
New Revision: 1645

Modified:
   pkg/Rcpp/inst/include/Rcpp/sugar/logical/and.h
   pkg/Rcpp/inst/include/Rcpp/sugar/logical/logical.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:49:27 UTC (rev 1644)
+++ pkg/Rcpp/inst/include/Rcpp/sugar/logical/and.h	2010-06-21 12:55:23 UTC (rev 1645)
@@ -165,6 +165,40 @@
 	
 } ;
 
+
+
+template <bool LHS_NA, typename LHS_T>
+class And_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( FALSE ) ;
+		} else{
+			BASE::set( lhs.get() ) ;
+		}
+	}
+		
+private:
+	const LHS_TYPE& lhs ;
+	bool rhs ;
+	
+} ;
+
+
 }
 }
 
@@ -177,5 +211,24 @@
 	return Rcpp::sugar::And_SingleLogicalResult_SingleLogicalResult<LHS_NA,LHS_T,RHS_NA,RHS_T>( lhs, rhs ) ;
 }
 
+template <bool LHS_NA, typename LHS_T>
+inline Rcpp::sugar::And_SingleLogicalResult_SingleLogicalResult<LHS_NA,LHS_T>
+operator&&( 
+	const Rcpp::sugar::SingleLogicalResult<LHS_NA,LHS_T>& lhs, 
+	bool rhs
+){
+	return Rcpp::sugar::And_SingleLogicalResult_bool<LHS_NA,LHS_T>( lhs, rhs ) ;
+}
 
+template <bool LHS_NA, typename LHS_T>
+inline Rcpp::sugar::And_SingleLogicalResult_SingleLogicalResult<LHS_NA,LHS_T>
+operator&&( 
+	bool rhs, 
+	const Rcpp::sugar::SingleLogicalResult<LHS_NA,LHS_T>& lhs
+){
+	return Rcpp::sugar::And_SingleLogicalResult_bool<LHS_NA,LHS_T>( lhs, rhs ) ;
+}
+
+
+
 #endif

Modified: pkg/Rcpp/inst/include/Rcpp/sugar/logical/logical.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/sugar/logical/logical.h	2010-06-21 12:49:27 UTC (rev 1644)
+++ pkg/Rcpp/inst/include/Rcpp/sugar/logical/logical.h	2010-06-21 12:55:23 UTC (rev 1645)
@@ -1,6 +1,6 @@
 // -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; tab-width: 8 -*-
 //
-// sugar_forward.h: Rcpp R/C++ interface class library -- forward declaration for Rcpp::sugar
+// logical.h: Rcpp R/C++ interface class library -- 
 //
 // Copyright (C) 2010 Dirk Eddelbuettel and Romain Francois
 //



More information about the Rcpp-commits mailing list