[Rcpp-commits] r803 - pkg/Rcpp/src/Rcpp
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Mon Mar 1 13:48:18 CET 2010
Author: romain
Date: 2010-03-01 13:48:18 +0100 (Mon, 01 Mar 2010)
New Revision: 803
Modified:
pkg/Rcpp/src/Rcpp/Named.h
Log:
minor updates to syntactic sugar allowing for _ to be used as a placeholder for a missing argument
Modified: pkg/Rcpp/src/Rcpp/Named.h
===================================================================
--- pkg/Rcpp/src/Rcpp/Named.h 2010-03-01 11:13:31 UTC (rev 802)
+++ pkg/Rcpp/src/Rcpp/Named.h 2010-03-01 12:48:18 UTC (rev 803)
@@ -50,6 +50,16 @@
*/
Named( const std::string& tag ) : object(R_NilValue), tag(tag){} ;
+ /**
+ * This allows the syntax :
+ * Language( "rnorm", Named( "mean" ) = 10 ) ;
+ */
+ template <typename T>
+ Named& operator=( const T& o ){
+ object = wrap( o ) ;
+ return *this ;
+ }
+
template<typename T>
Named( const std::string& tag, const T& value ) : object(), tag(tag) {
object = wrap( value ) ;
@@ -72,7 +82,7 @@
~NamedPlaceholderProxy(){}
template <typename T>
- Named operator=( const T& object ){
+ Named operator=( const T& object ) const {
return Named( name, object ) ;
}
@@ -84,9 +94,10 @@
public:
NamedPlaceHolder(){}
~NamedPlaceHolder(){}
- NamedPlaceholderProxy operator[]( const std::string& arg){
+ NamedPlaceholderProxy operator[]( const std::string& arg) const {
return NamedPlaceholderProxy( arg ) ;
}
+ operator SEXP() const { return R_MissingArg ; }
} ;
} // internal
More information about the Rcpp-commits
mailing list