Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR would fix some problems in PR#2117.
It would solve the AppVeyor compile error. Probably it is a bug in the VS compiler.
As Add conversion from/to std::optional nlohmann/json#2117 (comment) said, I found some problems.
2.a. I used these code to detect but just found
JSON_HAS_CPP_17 = False
in all travis jobs.Thus, All travis jobs didn't run the testcase -
TEST_CASE("std::optional")
, and those all code aboutoptional
were not compiled.I add a new travis task for c++17.
2.b. I also found the actual behavior, which would also happen in linux:
And the testcase
SECTION("null")
didn't call the expected method either and raise an excepiton -"[json.exception.type_error.302] type must be object, but is null"
.I agree with this view:
Thus, they would not call the method
from_json(basi_json, std::option<T>)
never. This is why an exception is raised inSECTION("null")
.Related Problem:
Different results in Clang and GCC when casting to std::optional
Why is a cast operator to std::optional ignored?
specification of std::optional constructor regarding cast operators