daqana / dqrng

Fast Pseudo Random Number Generators for R
https://daqana.github.io/dqrng/
Other
42 stars 8 forks source link

Bug: Compile-time and runtime-polymorphism do not work together #65

Open hsloot opened 1 year ago

hsloot commented 1 year ago

Problem

Some of boost's internal functions are fully specialized for dqrng::random_64bit_generator; see below. However, this specialization works for dqrng::random_64bit_generator only and not for any of its derived classes. See also https://stackoverflow.com/a/27988380.

https://github.com/daqana/dqrng/blob/f3a80023da2c08405e0150cb6b9286c866ab41f4/inst/include/dqrng_distribution.h#L41-L63

Possible solutions

I do not know if there is a natural fix as the original template definitions are part of the boost headers. Other than that, either all derived classes of dqrng::random_64bit_generator should have the same specialization or only dereferenced pointer-to-dqrng::random_64bit_generator should be passed into any distribution.

rstub commented 1 year ago

For now it looks like adding the same specialization is the way to go. In addition, I should also investigate to what extend these specialization are actually needed, i.e. if they still give a performance advantage.