Skip to content

ValueIterator operators -> and * must be const #1249

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

Closed
BillyDonahue opened this issue Dec 21, 2020 · 0 comments · Fixed by #1250
Closed

ValueIterator operators -> and * must be const #1249

BillyDonahue opened this issue Dec 21, 2020 · 0 comments · Fixed by #1250

Comments

@BillyDonahue
Copy link
Contributor

Describe the bug

As discovered in #1216, The C++20 std::reverse_iterator<ValueIterator> cannot perform ->, at least not in GCC.
This is because ValueIterator operators -> and * are const-incorrect.

To Reproduce

Json::Value v;
v["k1"] = "v1";
std::reverse_iterator it(value.end());
auto s = it->asString();  // This fails to compile, but `(*it).asString()`; is fine.

Expected behavior

operator-> and operator* should be const in ValueIterator as they are in ValueConstIterator.
Dereferencing an iterator is always a logical const operation, as providing such access does not change the iterator.

Desktop (please complete the following information):

  • OS: in my case, MacOS, using homebrew GCC-10.
  • Meson version N/A
  • Ninja version N/A

Additional context

A commit was made for this on #1216, but we could make it a standalone bugfix independent of C++20.
14e15b6

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 a pull request may close this issue.

1 participant