[Rcpp-devel] Rcpp packages that use Boost.Geometry?
Robi Ragan
robi.ragan at sjsu.edu
Sat Feb 22 00:36:53 CET 2014
On Feb 20, 2014, at 9:58 AM, Dirk Eddelbuettel <edd at debian.org> wrote:
>
> My RcppBDT has a few simple as<> / wrap converters for different types of the
> Boost Date_Time library. It so happens that CRAN just asked for an update (as
> the released package is 1 1/2 years old, the repo code is younger).
>
> Until I update that (probably this week), look at the GitHub repo which is
> current, not the older CRAN package or R-Forge repo.
>
> https://github.com/eddelbuettel/rcppbdt
>
> Dirk
>
> --
> Dirk Eddelbuettel | edd at debian.org | http://dirk.eddelbuettel.com
Thanks,
The last time I went after this I looked in the CRAN version and did not see anything. I see them in this github version.
In the example code on your webpage where you create custom as and wrap using BDT you make some forward declarations after calling RcppCommon.h, before you call the boost header file.
----------CODE------------
#include <RcppCommon.h>
#include <boost/date_time/gregorian/gregorian_types.hpp> // Gregorian calendar types, no I/O
namespace Rcpp {
// 'date' class boost::gregorian::date
//
// non-intrusive extension via template specialisation
template <> boost::gregorian::date as(SEXP dt);
//
// non-intrusive extension via template specialisation
template <> SEXP wrap(const boost::gregorian::date &d);
}
------ END CODE -----------------
In the package on github I don't see this and I was able to replicate your example code without those forward declarations in a test package I am using to learn how to do things.
Is that something unique here or are those declarations not needed in a package?
Also I just noticed that I had #include <Rcpp.h> before I defined the template specializations and the code still compiled and the examples ran correctly, but in the Extensions Vignette it says:
// this must appear after the specialization,
// otherwise the specialization will not be seen by Rcpp types
#include <Rcpp.h>
And I don't find any use of Rcpp.h in the cpp files in the package to try to understand what is going on.
Again any help is appreciated.
Robi Ragan
Assistant Professor of Economics
San Jose State University
http://userwww.service.emory.edu/~rragan
More information about the Rcpp-devel
mailing list