molpopgen / fwdpp

fwdpp is a C++ template library for implementing efficient forward-time population genetic simulations
http://fwdpp.readthedocs.io
GNU General Public License v3.0
27 stars 11 forks source link

Eliminate inheritance hierarchies for mutation and gamete #100

Open molpopgen opened 6 years ago

molpopgen commented 6 years ago

The current inheritance hierarchies for these types were originally developed so that fwdpp could use static_assert to enforce concepts via std::is_base_of.

Given that the library does not (easily) support population w/multiple mutation types at run time (although the current pop types do indeed allow for that), inheritance hierarchies should be removed and the library should rely on compile-time "duck typing" based on a minimal set of requirements to define a mutation.

The same arguments apply to the concept of "gamete".

molpopgen commented 6 years ago

Side effects include:

  1. Undoing tuple-based constructors introduced in #59 and #62. That's fine, as these changes can be viewed as a feature-creep caused by stuff I wanted in fwdpy11, but that can be done there via a different mechanism.

  2. Assignment of the neutral field would have to be handled differently, as we could no longer rely on dispatch to the base class. Again, easy enough.

  3. The popgenmut size would shrink by 8 bytes, which is cool!

  4. The design of the changes being introduced in #95 may no longer be desirable. Rather, it would be preferable to model those concepts over what was done in #90, and use ADL instead of member functions.

molpopgen commented 6 years ago

Useful to note that doing this would pre-adapt the library for C++20's "concepts".