eddelbuettel / bh

R package providing Boost Header files
85 stars 33 forks source link

Adding Mp11 #62

Closed nbenn closed 4 years ago

nbenn commented 4 years ago

Would it be possible to add the Boost Mp11 library to BH? I believe it‘s header-only.

eddelbuettel commented 4 years ago

Looks useful, so let's add it at the next round (which may be a few months off though, at least as a full CRAN release).

Have you used Mp11 yet?

nbenn commented 4 years ago

I'm currently using Mp11 in a package as a solution to roughly the following problem:

  1. I create an object like an arma::Mat<int> or arma::SpMat<double> and hold onto it via an Rcpp::Xptr
  2. When passing the SEXP representing the Xptr back to C++, I need to remember the original type and instantiate the Xptr again using the correct type (as template parameter).

How I'm doing this is outlined in my answer to my own SO question. If you're interested in having a look and have an opinion on the sensibility/execution of my undertaking, I'd be keen on hearing about it (no pressure, just in case you're interested).

To my untrained eye, Mp11 looks like a work of art, I did enjoy learning about it during the past days a lot.

Side note

The kludgy recursive type list interation, I implemented myself will no longer be necessary as soon as Rtools 40 goes out of beta and c++14 features become available. This will allow for very succinct implementation of what I'm after, by using `mp11::mp_with_index` (providing iteration, most likely in a more robust way than I came up with) and generic lambdas (instead of function objects).

nbenn commented 4 years ago

I'll fork bh and add Mp11 for my own use for the time being. If you're interested, I can open a PR.

eddelbuettel commented 4 years ago

Forking is a good approach for now. The procedure is pretty straightforward -- see the file local/scripts/CreateBoost.sh to which you'd add mp11 under boostextra. After that I have to do some polishing to comply with CRAN Policies (i.e. need to shorten some path and some stuff) which is documented in ChangeLog and NEWS and which you don't need for a local package. That should get you going.

And I probably don't need a PR for the one-line change to add mp11 ... but the testing is appreciated,

eddelbuettel commented 4 years ago

Preparing BH 1.72.0 now based on last week's Boost 1.72 release -- with mp11.