[Rcpp-devel] operator<< issues

Iñaki Úcar i.ucar86 at gmail.com
Tue Mar 20 11:42:27 CET 2018

2018-03-20 4:33 GMT+01:00 Tim Keitt <tkeitt at utexas.edu>:
> Why not something like:
> Rcpp::sourceCpp(code='
>   #include <Rcpp.h>
>    using Rcpp::Rcout;
>    // [[Rcpp::export]]
>    void print_addr(SEXP x){
>                 Rcout << static_cast<void*>(x) << std::endl;
>  }')
> I'm not sure why one would expect Rcpp types to automatically yield a
> pointer appropriate for printing.

I may have my own reasons for that, but that's not the point here. The
point is that I expected a homogeneous behaviour across Rcpp classes
when any object is passed to operator<< (i.e., print *something*).

By grepping the source, I discovered that Matrix and Vector have an
implementation of operator<<, but not the other classes.

Of course, this is a minor issue, because anyone is able to define
this operator if needed. I simply wanted to note it here, just in case
Dirk considered that all classes should have a well-defined one.



More information about the Rcpp-devel mailing list