[Rcpp-devel] RcppModules with templated class
Dr Gregory Jefferis
jefferis at mrc-lmb.cam.ac.uk
Mon Sep 1 14:40:12 CEST 2014
Dear Dirk,
Many thanks for your quick (as ever) response.
On 1 Sep 2014, at 13:27, Dirk Eddelbuettel wrote:
> But in this case consider that
> a) R itself only knows double so at some point both variants need to
> be
> promoted up
Yes, the code presently includes a static cast to the template scalar
type on the way in and a static cast to double on the way out. These
should be noops when the template scalar type is double.
Incidentlally the reason to do this is that the objects may be reused
repeatedly from R and can contain a large number of stored coordinates
– for which using floats obviously has a space advantage.
> b) Rcpp does a lot of magic for the C++ classes / member functions
> which
> become callable by R BUT recall that R does not have type signatures.
> So foo(const double & x) and foo(const float & x) look the same to
> R.
I don't think that should be a problem in my case as the entry point for
R always expects double inputs.
> | So is there a way round this? Do I have to write an explicit wrap
>
> Maybe, or maybe bite the bullet on this one now, and just typedef to
> one of
> your two implementations?
I'm not sure that I understand this point, but it may be what I have
already tried. What I was trying to do was write templated code, typedef
two separate types one for double, one for float and then export each of
them separately.
Many thanks,
Greg.
--
Gregory Jefferis, PhD Tel: 01223 267048
Division of Neurobiology
MRC Laboratory of Molecular Biology
Francis Crick Avenue
Cambridge Biomedical Campus
Cambridge, CB2 OQH, UK
http://www2.mrc-lmb.cam.ac.uk/group-leaders/h-to-m/g-jefferis
http://jefferislab.org
http://flybrain.stanford.edu
More information about the Rcpp-devel
mailing list