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

Use Data instead of DataConstRef internally #288

Open
LourensVeen opened this issue Feb 16, 2024 · 1 comment
Open

Use Data instead of DataConstRef internally #288

LourensVeen opened this issue Feb 16, 2024 · 1 comment

Comments

@LourensVeen
Copy link
Contributor

DataConstRef is rather tricky because of its weird Python-style sometimes-value-sometimes-reference semantics, which don't integrate well with the concept of constness. This is causing trouble when we use it internally, and we're probably better off just using Data everywhere internally so we don't need weird hacks in mocks and tests. All this of course while we await that magical time when we figure out how to cleanly integrate sometimes-value-sometimes-reference semantics with constness and make it all perfect.

@LourensVeen
Copy link
Contributor Author

Actually, it seems like a DataConstPtr would be better. This would be derived from DataConstRef, and add copy-assignment and move-assignment operators. That would make it compatible with standard containers, and would still keep the referred-to data from being modified. We could also safely add conversions from DataConstRef to DataConstPtr and back (back is automatic if DCP derives from DCR).

The only place where DataConstPtr wouldn't be able to replace DataConstRef is as the return value of DCR::operator[] or DCP::operator[], because that would break constness. So that will remain DataConstRef.

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

No branches or pull requests

1 participant