[Rinside-commits] r238 - pkg/inst/examples/standard

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Thu May 3 01:57:55 CEST 2012


Author: edd
Date: 2012-05-03 01:57:55 +0200 (Thu, 03 May 2012)
New Revision: 238

Modified:
   pkg/inst/examples/standard/rinside_sample12.cpp
Log:
output vector via std::copy to output iterator


Modified: pkg/inst/examples/standard/rinside_sample12.cpp
===================================================================
--- pkg/inst/examples/standard/rinside_sample12.cpp	2012-04-08 22:27:52 UTC (rev 237)
+++ pkg/inst/examples/standard/rinside_sample12.cpp	2012-05-02 23:57:55 UTC (rev 238)
@@ -14,10 +14,14 @@
 
     Rcpp::CharacterVector res = R.parseEval(cmd); // parse, eval + return result
 
-    for (int i=0; i<res.size(); i++) {
-	std::cout << res[i] << " ";
+    for (int i=0; i<res.size(); i++) {  // loop over vector and output
+	std::cout << res[i];
     }
     std::cout << std::endl;
+
+    std::copy(res.begin(), res.end(), 	// or use STL iterators 
+	      std::ostream_iterator<char*>(std::cout));
+    std::cout << std::endl;
     
     exit(0);
 }



More information about the Rinside-commits mailing list