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

add new is_constructible_* traits used in from_json #1301

Merged
merged 2 commits into from
Oct 18, 2018

Conversation

theodelrieu
Copy link
Contributor

@theodelrieu theodelrieu commented Oct 16, 2018

is_compatible_* traits were used in from_json, but it made no sense
whatsoever, since they check if a type can be converted TO json.

It used to work because of non-SFINAE correctness + json_ref
unconstrained variadic template constructor.

SFINAE checks are becoming quite complex, we need a specification of
some sort describing:

  • which concepts the library uses
  • how the conversion to/from json works in detail

Having such a specification would really help simplifying the current
code (as well as having meaningful checks).

Fixes #1299


Pull request checklist

Read the Contribution Guidelines for detailed information.

  • Changes are described in the pull request, or an existing issue is referenced.
  • The test suite compiles and runs without error.
  • Code coverage is 100%. Test cases can be added by editing the test suite.
  • The source code is amalgamated; that is, after making changes to the sources in the include/nlohmann directory, run make amalgamate to create the single-header file single_include/nlohmann/json.hpp. The whole process is described here.

is_compatible_* traits were used in from_json, but it made no sense
whatsoever.

It used to work because of non-SFINAE correctness + json_ref
unconstrained variadic template constructor.

SFINAE checks are becoming quite complex, we need a specification of
some sort describing:

* which concepts the library uses
* how the conversion to/from json works in detail

Having such a specification would really help simplifying the current
code (as well as having meaningful checks).

Fixes !1299
@nlohmann
Copy link
Owner

I can only trust the code - I can't provide a thorough review right now.


// This trait checks if JSONSerializer<T>::from_json(json const&) exists
// this overload is used for non-default-constructible user-defined-types
template <typename BasicJsonType, typename T, typename = void>
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe add a comment on whether or not 'T' is expected to be a concrete type (string) or is allowed to be a CV-qualified type (string const&). It's not clear if these need std::decay's in there or whether the layer above it should add them?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

IIRC, the only places where CV-qualified types are specified in the current code is in is_detected related code.

I can add a comment at the top of the file.

@theodelrieu
Copy link
Contributor Author

I'll open an issue in the next few days to explain in detail what I meant in the commit message.

I hope it will be a lot clearer then :)

@coveralls
Copy link

coveralls commented Oct 17, 2018

Coverage Status

Coverage remained the same at 100.0% when pulling a946dfc on theodelrieu:fix/1299 into dd67293 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.

@nlohmann nlohmann self-assigned this Oct 18, 2018
@nlohmann nlohmann added this to the Release 3.3.1 milestone Oct 18, 2018
@nlohmann nlohmann merged commit 9294e25 into nlohmann:develop Oct 18, 2018
@nlohmann
Copy link
Owner

Thanks!

@theodelrieu theodelrieu deleted the fix/1299 branch October 18, 2018 22:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants