Hi Daniel,<br><br>Unfortunately, you cannot use // [[Rcpp::export]] to automagically export template functions.<br><br>The general alternative approach is to define a template implementation, and then dynamically dispatch to that implementation, e.g.<br><br>    template <typename T><br>    void doStuffImpl() { ... }<br><br>with dispatch as<br><br>    // [[Rcpp::export]]<br>    void doStuff(SEXP object) {<br>        switch (TYPEOF(object)) {<br>        case INTSXP: return doStuffImpl<IntegerVector>();<br>        case REALSXP: return doStuffImpl<NumericVector>();<br>        ...<br>        }<br>    }<br><br>Of course, the way you implement your dispatch could differ, but generally you need to manually map the opaque SEXP type to the appropriate Rcpp type (or otherwise)<br><br>Hope this helps,<br>Kevin<br><br>On Friday, May 1, 2015, daniel castro <<a href="mailto:danielcastrob@gmail.com">danielcastrob@gmail.com</a>> wrote:<br>> Hello,<br>><br>> I'm trying to build a function that calculates (for example) the log<br>> of all elements of a container. I want this container to be a vector,<br>> a Rcpp::numericVector , or perhaps a arama::colvec , so I'm trying<br>> with templates ,and it compiles without the // [[Rcpp::export]] part,<br>> but when I put it to export to R it doesn't work:<br>><br>> //declaration<br>> template<class T><br>> T Vlog(T vectorForm);<br>><br>> //code<br>> // [[Rcpp::depends(RcppArmadillo)]]<br>> // [[Rcpp::export]]<br>> template<class T><br>> T Vlog(T vectorForm)<br>> {<br>><br>><br>>    std::transform(vectorForm.begin(), vectorForm.end(),<br>> vectorForm.begin(), log);<br>>    return vectorForm;<br>> }<br>><br>><br>> gives 'T' was not declared in this scope.<br>><br>> if possible, How could I fix it?<br>><br>> Thank you in advance<br>> Daniel,<br>> _______________________________________________<br>> Rcpp-devel mailing list<br>> <a href="mailto:Rcpp-devel@lists.r-forge.r-project.org">Rcpp-devel@lists.r-forge.r-project.org</a><br>> <a href="https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel">https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel</a><br>>