Do not store the MigrationMatrix using unique_ptr
in DiscreteDemography
.
#781
Projects
Milestone
unique_ptr
in DiscreteDemography
.
#781
This design decision was convenient when
DiscreteDemography
was a standalone C++ class. (The unique pointer would storenullptr
for "no migration", returningNone
to Python.) However, it leads to complications implementingdeepcopy
for the demographic model.A likely side-effect is that accessing a model's
MigrationMatrix
may trigger a copy in the not-None
case.Solution: store an object, not a pointer. The object can easily model the concept of "empty migration matrix" without relying on
nullptr
. Adding anempty()
member function would suffice. Then, the Python side would returnNone
if empty, or a reference to the object otherwise.The text was updated successfully, but these errors were encountered: