Additionnal data in Simplex_tree are not copied
Opened this issue · 1 comments
VincentRouvreau commented
mglisse commented
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 thatdata_target=data_source;
compiles seems too strict (copying only ifdata_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.