Converting element of 'const Rcpp::CharacterVector&' to 'std::string'
I am wondering if there is a Rcpp way to convert an element or iterator of const CharacterVector& to std::string . If I try the following code void as(const CharacterVector& src) { std::string glue; for(int i = 0;i < src.size();i++) { glue.assign(src[i]); } } a compiler-time error will occurred: no known conversion for argument 1 from ‘const type {aka SEXPREC* const}’ to ‘const char*’ So far, I use C API to do the conversion: glue.assign(CHAR(STRING_ELT(src.asSexp(), i))); My Rcpp version is 0.10.2. By the way, I do know there is a Rcpp::as . glue.assign(Rcpp::as<std::string>(src[i])); the