Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rcpp inconsistency between std0x and non-std0x

Tags:

c++

r

c++11

rcpp

I've found an odd inconsistency between Rcpp which compiled with and without -std=c++0x.

Consider the expression

Function data_frame("data.frame");

GenericVector a;
a.push_back("17");

return data_frame(a, _["stringsAsFactors"]=0);

(ed. note: coercion to DataFrame in Rcpp actually thunks down to the R function, but doesn't allow the user to set that flag.)

In "old" C++ (w/o -std=c++0x set) this code works. In modern C++ (w/ -std=c++0x set), this fails, saying "cannot coerce class "pairlist" into a data.frame".

Obviously, this isn't the end of the world: I just don't use any newer features. However, I confess to being totally at a loss as to what causes this difference, and how to work around it without throwing C++11 away. Any ideas, anyone?

like image 943
JWLM Avatar asked Nov 14 '12 19:11

JWLM


2 Answers

Code targetting features of the new standard was written in Rcpp about 2 years ago.

But then, later we realized that CRAN did not accept the -std=c++0x flag for gcc (or equivalent flags for other compilers), and forcing the C++99 standard and therefore we cannot realistically use it.

Consequently we pretty much don't maintain the C++11 aware code. That's a shame because we'd really like to, but we prefer the exposure of being accepted in CRAN. Since we don't maintain, there are probably many things that don't work as they should.

This particular issue is probably easy to fix. And this will happen as soon as we get the green light on using C++11.

like image 59
Romain Francois Avatar answered Sep 28 '22 09:09

Romain Francois


We love C++11 and cannot wait to use it. But we cannot use it in uploads to CRAN (as per a decree of the CRAN maintainers who consider C++11 "non portable" at this point -- please complain to them, not us, of that irks you).

Consequently it is currently "barred". There is a bit of detection in RcppCommon.h and we define HAS_CXX0X. But we haven't really written code for this, as we can't (yet) per the previous paragraph.

So if you found a bug, please do us the favor and report it where request follow-ups to be sent: the rcpp-devel list. Reproducible is good, patches even better :)

like image 44
Dirk Eddelbuettel Avatar answered Sep 28 '22 10:09

Dirk Eddelbuettel