-
-
Notifications
You must be signed in to change notification settings - Fork 6.7k
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 conversions to complex types can lead to surprising and confusing errors #1116
Comments
The root of this problem is described in detail in #958, here you can show your support for the removal of Meanwhile, I would suggest ALWAYS using EDIT: The "blacklist" will also break code, I'm personally in favor of the drastic solution, since implementing the first one is hard, especially if trying to get everything right... |
Thank you Theo, I'm not surprised that this has come up before. I've reviewed #958 and up voted it. A few comments though:
Side note: personally I'd love to see the parsing and formatting decoupled from the json type itself (which would incidentally allow for more flexibility for formatting customization), but regardless of that, I think that a more strict control over conversions serves C++ developers better. |
Great, thanks!
|
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. |
Using std::vector as an example (since it's likely a popular scenario) illustrates how the implicit conversions (json::operator ValueType() const) result in a potentially frustrating errors:
Note that the assignment operator case (the last one) could be fixed by "more SFINAE": ignore any specializations of std::initializer_list. I don't see a generic solution for the other cases (this is just an example)
My suggestion is to scale back on the implicit conversions:
I realize that the 2nd choice seems a drastic departure and that some people are attracted to the initial convenience of implicit conversions (for large, complex project this short term convenience is likely a liability though).
Thank you!
The text was updated successfully, but these errors were encountered: