Hi guys, With some encouragement from Romain, I took a shot at implementing the ListOf<T> class. For now, everything's just in one big .cpp file here (later I can factor it out to .h and .cpp files). But please take a look here:
https://gist.github.com/kevinushey/7208681 I took Romain's suggestions from before and 1) have ListOf<T> inheriting from List directly, and 2) proxified operator[] so we can distinguish read / write (merci, Scott Meyers, for More Effective C++). Ultimately, most of it is boilerplate used so that the proxy is handled correctly. The class isn't too complicated, but it is surprisingly functional since it can leverage everything already available in Rcpp. It works well with the sugar functions and it can be handled by Rcpp attributes as-is as well. There are a couple of demonstrative examples at the bottom (to be written as a more formal test suite later). I would welcome any comments; I'm fairly inexperienced as a C++ programmer so I'm sure some things might be wrong. Things I know could be better and would appreciate some advice on: 1) Use Rcpp's traits system rather than TYPEOF for mapping template types to strings (ie. in validate), (eg: going from Rcpp classes to internal SEXP types; more generally, how can I navigate the traits namespace), 2) Extend lapply, sapply to infer types for applied templated functions from ListOf<T> classes, so for e.g. a ListOf<NumericVector> x and a template function add_1, we could just write lapply(x, add_1); rather than lapply(x, add_1<NumericVector>); Thanks! -Kevin _______________________________________________ Rcpp-devel mailing list Rcpp-devel@lists.r-forge.r-project.org https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel