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

Move constructor of list hook is missing #74

Open
gaohuazuo opened this issue Jan 12, 2022 · 0 comments
Open

Move constructor of list hook is missing #74

gaohuazuo opened this issue Jan 12, 2022 · 0 comments

Comments

@gaohuazuo
Copy link

gaohuazuo commented Jan 12, 2022

Currently, list hooks do not declare a move constructor. When moved, the copy constructor is called instead, resulting the moved-from hook still linked and the moved-to hook unlinked (https://godbolt.org/z/zKqqhbxz5). An consequence is that objects containing list hooks cannot be safely put inside some STL containers like std::vector (https://godbolt.org/z/vq765G5n5). Furthermore, it is not alway possible to implement a desired move constructor for the class containing list hooks, since link / unlink cannot be performed without the list object if the list has constant time size().

I think making the following changes to list hooks would make them safer and more broadly useful:

  • declare the move constructor as deleted
  • enabled with an option, add a move constructor that unlinks the moved-from hook and link the moved-to hook in its place
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