Davor, Kevin,
Allow to get into this intra-Vancouver exchange as I too dislike the sound of
"but this used to work"....
A simple modifcation (see below) seems to do the trick:
R> sourceCpp("/tmp/davor.cpp")
R> getString(c("The", "quick", "brown", "fox"), 2)
[1] "brown"
R> getString(c("The", "quick", "brown", "fox"), 0)
[1] "The"
R>
Here I do in fact go via char*. I too have the feeling that that didn't use
to be necessary --- but then "fear not" as we are currently getting better
string classes in Rcpp thanks to Romain (and to Hadley for funding). So I
would just sit tight and wait things. And maybe send us a new unit test for
two as the dozen or so we have for CharacterVector didn't catch this.
Dirk (hoping he understands what Davor was after in the first place...)
#include <Rcpp.h>
using namespace Rcpp;
// [[Rcpp::export]]
std::string getString(CharacterVector cv, int pos) {
char *c = cv[pos];
std::string s(c);
return s;
}
--
Dirk Eddelbuettel | [email protected] | http://dirk.eddelbuettel.com
_______________________________________________
Rcpp-devel mailing list
[email protected]
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel