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

Bug in listings 6.9 and 6.10 #52

Open
lczech opened this issue Feb 21, 2024 · 0 comments
Open

Bug in listings 6.9 and 6.10 #52

lczech opened this issue Feb 21, 2024 · 0 comments

Comments

@lczech
Copy link

lczech commented Feb 21, 2024

Hi there!

Listing 6.9 and 6.10 contain a comparison of a unique_ptr with a raw pointer:

head!=get_tail()

See here and here, which fails to compile.

This is done correctly in other places in Listing 6.10 though, where head.get() is used instead.

Furthermore, Listing 6.9 declares a unique_ptr const

std::unique_ptr<node> const old_head=std::move(head);

This fails to compile as well, see here, as the const pointer cannot be returned any more.

Interestingly, none of these occur in the book. It might hence be better to use the code from the book instead. I wonder why those two are out of sync though :-)

Lastly, in Listing 6.9, a local object is moved, see here

return std::move(head_lock);

This prevents copy elision, and leads to an error with my compiler as well. A simple return would do here. This is in the Listing here and in the book.

Cheers
Lucas

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