Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Additionnal data in Simplex_tree are not copied #1127

Open
VincentRouvreau opened this issue Aug 30, 2024 · 1 comment · May be fixed by #1151
Open

Additionnal data in Simplex_tree are not copied #1127

VincentRouvreau opened this issue Aug 30, 2024 · 1 comment · May be fixed by #1151

Comments

@VincentRouvreau
Copy link
Contributor

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

@mglisse
Copy link
Member

mglisse commented Aug 30, 2024

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 ([Simplex tree] Additional copy constructor for Simplex_tree #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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants