Length from scratch (ish)
#include <Rcpp.h>
using namespace Rcpp;
// [[Rcpp::export]]
int cpp_length(NumericVector x) {
int out = 0;
for (NumericVector::iterator iter = x.begin(); iter != x.end(); iter++) {
out++;
}
return out;
}
/*** R
cpp_length(1:20)
#> [1] 20
*/