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

json_pointer<>::back() should be const #1764

Closed
gcerretani opened this issue Sep 26, 2019 · 3 comments
Closed

json_pointer<>::back() should be const #1764

gcerretani opened this issue Sep 26, 2019 · 3 comments

Comments

@gcerretani
Copy link
Contributor

gcerretani commented Sep 26, 2019

  • What is the issue you have?
    It is impossible su use json_pointer<>::back() on const json_pointer.

  • What is the expected behavior?
    I expect to be able to use on a const. Since it returns a const std::string&, and since it is implemented with std::vector<>::back() that has a const overload, I expect the json_pointer<>::back() has to be declared const.

  • And what is the actual behavior instead?
    The function is not marked as const.

  • Did you use a released version of the library or the version from the develop branch?
    tested with 3.7.0.

@nlohmann
Copy link
Owner

Thanks for reporting! I think this can be indeed easily fixed. I'll make a PR.

nlohmann added a commit that referenced this issue Oct 3, 2019
Make json_pointer::back const (resolves #1764)
@nlohmann nlohmann self-assigned this Oct 3, 2019
@nlohmann nlohmann added this to the Release 3.7.1 milestone Oct 3, 2019
OmnipotentEntity pushed a commit to OmnipotentEntity/json that referenced this issue Oct 20, 2019
@gcerretani
Copy link
Contributor Author

In the release notes of #v3.7.1 release v3.7.1, the fix is not correctly described:

  • Added const version for json_pointer::back.

The link points to basic_json::back instead of json_pointer::back. Furthermore, the version const has not been added, it just replaces the old non const version.

@nlohmann
Copy link
Owner

Good catch! I fixed the release notes accordingly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants