-
-
Notifications
You must be signed in to change notification settings - Fork 6.9k
Build issue with std::optional #4740
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
Comments
Adding the following code is a workaround: namespace nlohmann |
Problem with #ifndef JSON_USE_IMPLICIT_CONVERSIONS in from_json.hpp I think. |
Good catch! However, after replacing the const auto t0 = Example_4740();
const auto j = nlohmann::json(t0);
CHECK(j.dump() == "{\"host\":null,\"port\":null}"); all is fine, but adding auto t1 = j.get<Example_4740>();
CHECK(!t1.host.has_value());
CHECK(!t1.port.has_value()); again breaks the build. Now, I am unsure why we have the check for I created a PR #4742 to test this. Please take a look. |
I think the JSON_USE_IMPLICIT_CONVERSIONS check should be removed. The test code should compile and work with JSON_USE_IMPLICIT_CONVERSIONS set to 0 or set to 1. |
Thanks, it does - the MR has a green CI and I only need to add another test to improve the code coverage. |
Description
Hi,
So great the library now support std::optional!
But I have a build issue with the following simple code.
Do you have any idea?
Thank you.
Vincent
Reproduction steps
Just compile the code
Expected vs. actual results
Compile should be successful
Minimal code example
Error messages
Compiler and operating system
Visual Studio 2022
Library version
3.12.0
Validation
develop
branch is used.The text was updated successfully, but these errors were encountered: