-
-
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
Json should not be constructible with 'json*' #448
Comments
Maybe the default to_/from_json should be implemented just for the common C++ types (bool, std::string, std::map, std::vector) and not in terms of BasicJson::whatever_t, and if you specialize basic_json then you have to also manually opt-in to the right to_/from_json overloads? |
If I remember correctly, there was a constructor for each So I think we should keep those overloads for now, to keep backward compatibility. To avoid this implicit conversion, I guess a simple Unfortunately I don't have a laptop at hand until Sunday to test this |
@theodelrieu I agree in both points, and I think I won't have time to fix this this week either. |
I have done this and it seems to work:
I'm not 100% that the decay is necessary. |
Fixed using @jaredgrubb 's proposal. |
I don't think the decay is useful, but that's a minor thing. Thanks for the fix! |
I shall remove the decay then. |
I had something like this:
This was a bug (I need to dereference the pointer), but json constructor accepts it as a boolean type because it's finding this overload:
The problem with 'bool' is that it captures a lot of things. Classes with 'operator bool()' are also being caught.
I can think of some simple changes (SFINAE something), but I'm not sure how well they work with arbitrary BasicJsonType's.
The text was updated successfully, but these errors were encountered: