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

PlRecord needs to define move constructor (possibly other classes as well) #40

Open
kamahen opened this issue Apr 13, 2023 · 1 comment

Comments

@kamahen
Copy link
Member

kamahen commented Apr 13, 2023

All classes that contain a pointer or similar need to define a move constructor as well as a copy constructor because the default move constructor doesn't do the right thing. E.g., for PlRecord, both the copy and move constructors need to call Plx_duplicate_record(), and then the destructor can call Plx_erase().
(Need to do some experimentation to determine if the move constructor should also zero the record_t field, which is checked in the destructor before calling Plx_erase().)
(It might be necessary to keep a separate reference count in PlRecord.

It's not clear what PlQuery needs, but probably it also doesn't work properly with the default move constructor.

These changes are not in #39 - for the time being, I suggest documenting the problem because the correct fixes are not obvious.

@kamahen
Copy link
Member Author

kamahen commented Apr 18, 2023

The move constructors have been added, but leaving this open because PlRecord should act like a "smart pointer", taking advantage of the way PL_duplicate_record() and PL_erase() work (with reference counts). For now, PlRecord has been renamed to PlRecordRaw, to emphasize that it isn't "smart".

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