-
-
Notifications
You must be signed in to change notification settings - Fork 6.7k
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
Conversation
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
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> |
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.
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?
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.
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.
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 :) |
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! |
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:
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.
include/nlohmann
directory, runmake amalgamate
to create the single-header filesingle_include/nlohmann/json.hpp
. The whole process is described here.