-
-
Notifications
You must be signed in to change notification settings - Fork 6.6k
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
implicit conversion failure #2128
Comments
I tried the code with Xcode after removing the boost stuff. This works: auto j = nlohmann::json::parse(R"([ { "name" : "FOO" }, { "name" : "BAR" } ])");
my_struct::names n1 = j[0]["name"];
my_struct::names n2 = j[1]["name"];
const json_data_format<my_struct> format = j[0]; |
|
FYI, the code works perfectly with Visual Studio 2019 (tried with 16.5.4). Probably it is really a bug in the Visual Studio 2015 compiler/linker. Unfortunately, I've not been able to reproduce a simpler example. |
It also works in my env - Visual Studio 2019. |
Beats me. I try to install vs2015 and reproduce, but none is smooth. |
Other interesting things I've seen:
Unfortunately godbolt does not support Visual Studio 2015 (even if I've seen a MSVC 2015 (WINE), but I'm not sure is the same). However, if needed, I've pasted my code in this godbolt notebook. |
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. |
What is the issue you have?
Strange behavior of implicit conversion
Please describe the steps to reproduce the issue. Can you provide a small but working code example?
What is the expected behavior?
The json is correctly parsed.
And what is the actual behavior instead?
The parse fails because the lambda
get_if_not_null
is called withnullptr
as first argument (theconst char* key
). The code works correctly if the implicit conversion is replaced by an explicit conversion withauto format = element.get<json_data_format<my_struct>>();
Which compiler and operating system are you using? Is it a supported compiler?
Microsoft Visual C++ 2015 / Build Tools 14.0.25431.01, currently supported. I've tried also with GCC 7 and everything seems to work as expected.
Did you use a released version of the library or the version from the
develop
branch?v3.7.3
The text was updated successfully, but these errors were encountered: