[Rcpp-commits] r486 - in pkg: inst src src/Rcpp
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Wed Jan 27 16:50:01 CET 2010
Author: romain
Date: 2010-01-27 16:50:01 +0100 (Wed, 27 Jan 2010)
New Revision: 486
Modified:
pkg/inst/ChangeLog
pkg/src/CharacterVector.cpp
pkg/src/Rcpp/CharacterVector.h
Log:
CharacterVector::StringProxy gains a <<(ostream& operator
Modified: pkg/inst/ChangeLog
===================================================================
--- pkg/inst/ChangeLog 2010-01-27 15:33:16 UTC (rev 485)
+++ pkg/inst/ChangeLog 2010-01-27 15:50:01 UTC (rev 486)
@@ -2,6 +2,9 @@
* src/Rcpp/CharacterVector.h: CharacterVector::StringProxy
gains implicit conversion to std::string
+
+ * src/Rcpp/CharacterVector.h: CharacterVector::StringProxy
+ gets a printing operator <<(std::ostream& )
* src/Rcpp/Environment.h: removed the static
Environment::RCPP_NAMESPACE which caused problems when
Modified: pkg/src/CharacterVector.cpp
===================================================================
--- pkg/src/CharacterVector.cpp 2010-01-27 15:33:16 UTC (rev 485)
+++ pkg/src/CharacterVector.cpp 2010-01-27 15:50:01 UTC (rev 486)
@@ -82,6 +82,10 @@
return *this ;
}
+std::ostream& operator<<(std::ostream& os, const CharacterVector::StringProxy& proxy) {
+ os << CHAR(STRING_ELT( proxy.parent, proxy.index )) ;
+ return os;
+}
const CharacterVector::StringProxy CharacterVector::operator[](int i) const throw(index_out_of_bounds){
return StringProxy(const_cast<CharacterVector&>(*this), offset(i) ) ;
@@ -99,5 +103,4 @@
return StringProxy(*this, offset(i,j) ) ;
}
-
} // namespace
Modified: pkg/src/Rcpp/CharacterVector.h
===================================================================
--- pkg/src/Rcpp/CharacterVector.h 2010-01-27 15:33:16 UTC (rev 485)
+++ pkg/src/Rcpp/CharacterVector.h 2010-01-27 15:50:01 UTC (rev 486)
@@ -49,6 +49,9 @@
operator char*() const ;
operator std::string() const ;
+ /* printing */
+ friend std::ostream& operator<<(std::ostream& os, const StringProxy& proxy);
+
private:
CharacterVector& parent;
int index ;
More information about the Rcpp-commits
mailing list