The following should not compile:
#include <Rcpp.h>
#include <Rcpp/String.h>
using namespace Rcpp ;
// [[Rcpp::export]]
CharacterVector character_iterator1( const CharacterVector letters ){
std::string res ;
CharacterVector::const_iterator first = letters.begin() ;
CharacterVector::const_iterator last = letters.end() ;
while( first != last ){
*first = String("dan");
++first ;
}
return letters ;
}
// R code
# library(Rcpp11)
# library(attributes)
#
# sourceCpp("test.cpp")
#
# v <- letters
# result <- character_iterator1(v)
# result
# v
Currently it not only compiles, but actually modifies the Vector as evidenced in the output below.
[1] "dan" "dan" "dan" "dan" "dan" "dan" "dan" "dan" "dan" "dan" "dan" "dan"
[13] "dan" "dan" "dan" "dan" "dan" "dan" "dan" "dan" "dan" "dan" "dan" "dan"
[25] "dan" "dan"
[1] "dan" "dan" "dan" "dan" "dan" "dan" "dan" "dan" "dan" "dan" "dan" "dan"
[13] "dan" "dan" "dan" "dan" "dan" "dan" "dan" "dan" "dan" "dan" "dan" "dan"
[25] "dan" "dan"
Sorry for the repeated use of my name, but it's my go-to meaningless string.
The following should not compile:
Currently it not only compiles, but actually modifies the
Vectoras evidenced in the output below.Sorry for the repeated use of my name, but it's my go-to meaningless string.