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

fix from_json implementation for pair/tuple #708

Merged
merged 1 commit into from
Aug 24, 2017

Conversation

theodelrieu
Copy link
Contributor

Introduced by 6e4910d

Fixes #707

@mention-bot
Copy link

@theodelrieu, thanks for your PR! By analyzing the history of the files in this pull request, we identified @nlohmann, @himikof and @t-b to be potential reviewers.

@@ -262,11 +263,12 @@ TEST_CASE("constructors")

SECTION("std::tuple")
{
const auto t = std::make_tuple(1.0, "string", 42, std::vector<int> {0, 1});
const auto t = std::make_tuple(1.0, std::string{"string"}, 42, std::vector<int> {0, 1});
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you need to change "string" to std::string{"string"} here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because it was deduced as a const char* which you can not retrieve with get.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling 15c01a8 on theodelrieu:fix/from_json_tuple_pair into 9fd031b on nlohmann:develop.

Copy link
Owner

@nlohmann nlohmann left a 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.

{
p = {j.at(0), j.at(1)};
p = {j.at(0).template get<A1>(), j.at(1).template get<A2>()};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible that we'd have to support something like pair<int,int>? I think you'll save yourself a patch if you use get<0> and get<1> instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure I understood your point. Are you talking about std::get?
I don't see how it could be used here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Er, you're right. I was talking about std::get here, which is not what you're doing at all. I mis-read it. What you have looks good!

@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling bb1b4c9 on theodelrieu:fix/from_json_tuple_pair into e45eaf6 on nlohmann:develop.

@nlohmann nlohmann merged commit 5b71bf0 into nlohmann:develop Aug 24, 2017
@nlohmann
Copy link
Owner

Thanks!

@nlohmann nlohmann self-assigned this Aug 24, 2017
@nlohmann nlohmann added this to the Release 3.0.0 milestone Aug 24, 2017
@theodelrieu theodelrieu deleted the fix/from_json_tuple_pair branch August 24, 2017 10:40
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.

None yet

5 participants