[Rcpp-devel] Problem exposing constructor taking std::vector of user defined class to R using Rcpp-attributes and Rcpp-modules

Luke.Domanski at csiro.au Luke.Domanski at csiro.au
Thu Aug 22 22:14:56 CEST 2013


Excellent!

Thanks Romain. I'll get the new version and let you know how I go with both the toy and the real code.

> Symbol not found: __ZN1AI1BEC1ESt6vectorIS0_SaIS0_EE
>
> which is:
>
> $ c++filt __ZN1AI1BEC1ESt6vectorIS0_SaIS0_EE
> A<B>::A(std::vector<B, std::allocator<B> >)
>
> which I can quickly correct by implementing the constructor:
>
> A( std::vector<T> in_vec ) : vec_of_T(in_vec){}

Yes, I took the implementation of the A constructor out of the toy example as it did not influence the original error.

>
> Date: Thu, 22 Aug 2013 08:21:52 +0200
> From: Romain Francois <romain at r-enthusiasts.com>
> To: rcpp-devel at lists.r-forge.r-project.org
> Subject: Re: [Rcpp-devel] Problem exposing constructor taking
>             std::vector of user defined class to R using Rcpp-attributes and
>             Rcpp-modules
> Message-ID: <5215AE00.8000003 at r-enthusiasts.com>
> Content-Type: text/plain; charset=windows-1252; format=flowed
>
> Hello,
>
> The compiler tells you that :
>
> Library/Frameworks/R.framework/Versions/3.0/Resources/library/Rcpp/include/Rcpp/internal/export.h:90:
> error: no matching function for call to
> ?export_range__dispatch(SEXPREC*&, __gnu_cxx::__normal_iterator<B*,
> std::vector<B, std::allocator<B> > >&, Rcpp::traits::r_type_generic_tag)?
>
> The important thing to see here is "r_type_generic_tag"
>
>
> We currently only have versions of export_range__dispatch for these:
>
> -- strings:
>
> template <typename InputIterator, typename value_type>
> void export_range__dispatch( SEXP x, InputIterator first,
> ::Rcpp::traits::r_type_string_tag )
>
> -- primitive types (double, int, ...):
>
> template <typename InputIterator, typename value_type>
> void export_range__dispatch( SEXP x, InputIterator first,
> ::Rcpp::traits::r_type_primitive_tag )
>
> So we need one for the r_type_generic_tag :
>
> template <typename InputIterator, typename value_type>
> void export_range__dispatch( SEXP x, InputIterator first,
> ::Rcpp::traits::r_type_generic_tag )
>
>
> I just added it in svn. So now your code almost compiles. I did get a
>
> Symbol not found: __ZN1AI1BEC1ESt6vectorIS0_SaIS0_EE
>
> which is:
>
> $ c++filt __ZN1AI1BEC1ESt6vectorIS0_SaIS0_EE
> A<B>::A(std::vector<B, std::allocator<B> >)
>
> which I can quickly correct by implementing the constructor:
>
> A( std::vector<T> in_vec ) : vec_of_T(in_vec){}
>
>
> Then I can do this:
>
> # Reference Class of B
> B_R <- setRefClass( "B_R",
>      fields = list(id="numeric")
> )
> b1 <- new( "B_R", id = 1 )
> b2 <- new( "B_R", id = 1 )
> a <- new( A, list(b1,b2) )
>
>
> Romain
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20130822/d13b6359/attachment.html>


More information about the Rcpp-devel mailing list