Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Move constructor of list hook is missing

Open
#74 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
35/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
cpp
Domain
backend

Research direction

Start by locating the list hook declarations and their existing copy-construction behavior. Review how hooks are linked and unlinked during object movement, then determine how an option could control deleted versus link-preserving move construction. Done means moved hooks preserve correct moved-from and moved-to linkage and remain safe for use in STL containers.

Written by the indexing model from the issue text.

Description

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
Dominant language
C++
Stars
66
Forks
74
Avg merge
5h 22m
Merged PRs (30d)
1

Getting set up

We have not checked this project's setup files yet. Start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from boostorg/intrusive

All issues in boostorg/intrusive

Similar issues

More C++ issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.