GUDHI/gudhi-devel

Additionnal data in Simplex_tree are not copied

Opened this issue · 1 comments

Data in simplices was introduced in #1105 but these data are not copied when copying a Simplex_tree.
Should we do it ? Or just say in doc these data are volatile and not copied.
Also keep in mind #1121 that introduces a new kind of copy constructor

As explained in #1105 (comment), the ideal would be to have a way for the user to specify what happens to data (even to different parts of data) in special circumstances like copying, expansion, etc, but that's a bit complicated to set up. So, for not-too-surprising defaults

  • copy-constructor: I think copying data makes sense. We could not copy and default/value-initialize instead, arguing that data is some kind of cache, not a fundamental part of the tree, but that seems more surprising for the user. If they really do not want to copy, they can wrap their data type in a non-copying type.
  • transforming-constructor (#1121): if the type of data is unrelated between the 2 trees, obviously we cannot copy it. We could never copy data in this constructor. Copying only when Simplex_data is exactly the same in the 2 trees is a possibility, it may be useful, but it may also be confusing. Requiring that data_target=data_source; compiles seems too strict (copying only if data_target=data_source; compiles (tested with SFINAE or C++20 concepts) is a variant of "only if Simplex_data is the same" above). Adding one more optional functor parameter to the constructor is a possibility, although that may be overkill at this point. I am tempted by "no copy" at this point...

Note that currently data is also ignored in serialization.