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

Listing 6.11 - Compile Error #34

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

ITHelpDec
Copy link

@ITHelpDec ITHelpDec commented May 26, 2023

Consider changing line 23 from...

bucket_iterator find_entry_for(Key const& key) const

...to...
bucket_iterator find_entry_for(Key const& key)

Doesn't preserve const-ness, but fixes the following error, and allows for the code to run.

No viable conversion from returned value of type....
'std::__list_const_iterator<std::pair<int, int>, void *>'
...to function return type...
'ts::map<int, int>::bucket_type::bucket_iterator'
...(aka '__list_iterator<std::pair<int, int>, void *>')

Line 30...

Value value_for(Key const& key,Value const& default_value) const

...should then also be changed to...
Value value_for(Key const& key,Value const& default_value)

...to avoid the following compilation warning.

'this' argument to member function 'find_entry_for' has type...
`const ts::map<int, int>::bucket_type', ...
...but function is not marked const

- current function returns a mismatch of iterators (const vs non-const)

No viable conversion from returned value of type....
'std::__list_const_iterator<std::pair<int, int>, void *>'
...to function return type...
'ts::map<int, int>::bucket_type::bucket_iterator'
...(aka '__list_iterator<std::pair<int, int>, void *>')

- a better solution would be to preserve const-ness, but this will do for now
@ITHelpDec ITHelpDec mentioned this pull request May 26, 2023
- consider removing `const` to allow programme to compile

- 'this' argument to member function 'find_entry_for' has type...
- 'const ts::map<int, int>::bucket_type', ...
- ...but function is not marked const
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

Successfully merging this pull request may close these issues.

1 participant