On 7 January 2012 at 19:02, Romain François wrote: | Not thinking about a rewrite, just adding e.g. this for int: | | template <> inline int as<int>( SEXP x, | ::Rcpp::traits::r_type_primitive_tag ) { | return Rf_asInteger( x ) ; | } | | so that we let R's asInteger do the actual work, and Doug is right, it | does a better job than the current emplated version. | | For example this works: | | > fx <- cxxfunction( signature(x_="ANY"), ' int x = as<int>( x_ ); | return wrap(x); ', plugin="Rcpp") | > | > fx( "123" ) | [1] 123
Right. Specialisation makes sense as we just add features like the char-to-int cast. | However, | | > fx( c(1L, 3L ) ) | [1] 1 | | this passes, where as the current version complains that it should be a | single value. Which is a very useful test to have. Hmpf. Dirk -- "Outside of a dog, a book is a man's best friend. Inside of a dog, it is too dark to read." -- Groucho Marx _______________________________________________ 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