-
-
Notifications
You must be signed in to change notification settings - Fork 6.9k
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
Added Support for Structured Bindings #1391
Conversation
// We would have to make iteration_proxy_internal | ||
// Accessible to tuple_size and tuple_element in std namespace | ||
// However, as iteration_proxy_internal is private, | ||
// We will have to use a Hack to add Structured Bindings Support |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought we agreed on making iteration_proxy_internal
public?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made the necessary changes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not have much of a clue how LGTM or AppVeyor work so do they restart with the new commit or would I have to create a new one??
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You do not have to create a new one IIRC
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@theodelrieu thanks!
That's actually a nice feature
I just pushed a commit on my fork which is still a wip, but the basic use-case works (with non-member I had to move out There might be some refactoring to be done with Also, I have not tested edge-cases yet... @pratikpc What do you think about incorporating my changes in your PR? We can work out the remaining details if you want :) |
That's a superb change. In the commit we can possibly push the get function to the std namespace as well
Making it public and independent of iteration_proxy kills of all the problems we were facing. |
@theodelrieu the commit broke a Unit Test. One way to correct it is to add a Constructor in Basic Json class which accepts iteration_proxy_internal as an argument
However, my belief is that this is a temporary fix The error I faced was |
Oops, my bad, I only tested
That's illegal unfortunately, the I will make the code work on my box and let you know when I push! |
Oh.
The unit-tests now no longer fail after adding the Constructor. I would add a commit which shifts get back into the namespace as before |
I just push-forced on my fork, the fix was in
You can see the rules from cppreference |
@theodelrieu I can't find the changes. EDIT Should iteration_proxy_internal be renamed @theodelrieu ? |
It is still in namespace I do think the PR is complete, could you squash your commits? |
@theodelrieu how does one squash a commit exactly??? |
First, do not forget to run Once this is done, run |
@theodelrieu thanks!!! |
@theodelrieu The following tests FAILED: |
I’ll restart. |
Appveyor seems to work now. :) |
@nlohmann is it okay that we have made |
I am traveling right now, so I won’t be able to check before next week. But anything that brings us closer toward support of structured bindings is greatly appreciated! |
For further details, read #1388 and https://blog.tartanllama.xyz/structured-bindings/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me.
Thanks so much! |
Closes #1388.
[Describe your pull request here. Please read the text below the line, and make sure you follow the checklist.]
For further details, read #1388 and https://blog.tartanllama.xyz/structured-bindings/
Structured Bindings help simplify writing code and using this library greatly especially given the way they are implemented in C++17 and the addition of the items function.
The method of implementation ensures that Structured Bindings implementation can also be added in projects using C++11 with only C++17 being able to reap the benefits.
Pull request checklist
Read the Contribution Guidelines for detailed information.
include/nlohmann
directory, runmake amalgamate
to create the single-header filesingle_include/nlohmann/json.hpp
. The whole process is described here.Please don't
#ifdef
s or other means.