-
-
Notifications
You must be signed in to change notification settings - Fork 6.8k
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
Deserialization: if class is_constructible from std::string wrong from_json overload is being selected, compilation failed #3171
Comments
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Bad bot! I've come across the same issue. |
Same issue here with Eigen::Matrix |
0e694b4 strikes again. There are now several bugs related to this commit. |
I have a fix and am working on unit tests. @nickanthony-dgl Could you share a minimal example demonstrating your issue? I'm not sure how it's related given we're talking about classes constructible from string. |
Constrain from_json() overload for ConstructibleStringType to not accept json_ref and require assignability. Re-enable C++14 tests on Clang <4.0. Fixes nlohmann#3171, nlohmann#3312, nlohmann#3384. Maybe fixes nlohmann#3267.
Constrain from_json() overload for ConstructibleStringType to not accept json_ref and require it to be assignable from basic_json::string_t. Re-enable C++14 tests on Clang <4.0. Fixes nlohmann#3171. Fixes nlohmann#3267. Fixes nlohmann#3312. Fixes nlohmann#3384.
Constrain from_json() overload for StringType to not accept json_ref and require it to be assignable, instead of constructible, from basic_json::string_t. Re-enable C++14 tests on Clang <4.0. Fixes nlohmann#3171. Fixes nlohmann#3267. Fixes nlohmann#3312. Fixes nlohmann#3384.
When some hierarchy exists and base class has overload for from_json function, but if child is constructible from string compilation failing because compiler selecting overload
void from_json(const BasicJsonType& j, ConstructibleStringType& s)
over function that was prepared for base classvoid from_json(const json& j, Base& b)
What is the issue you have?
As described above, and looks like that on previous release versions it was working as expected. (Code compiles and deserialization was correct).
If add specific from_json overload for derived class, everything is working as expected.
Bug can be reproduced on latest develop branch, checked from 3.9.1 to 3.10.3 code compiles as expected.
Looks like this is regression commit.
Please describe the steps to reproduce the issue.
Can you provide a small but working code example?
https://godbolt.org/z/e75a67oTj
What is the expected behavior?
Compilation should be successful, base class overload should be selected over overload for classes that can be constructed from string.
And what is the actual behavior instead?
Compilation failed.
But if specific from_json overload for derived class was added, everything is working as expected.
Which compiler and operating system are you using?
Which version of the library did you use?
develop
branchIf you experience a compilation error: can you compile and run the unit tests?
The text was updated successfully, but these errors were encountered: