You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Mar 26, 2020. It is now read-only.
I'm trying to use this json serializer with long ints and unsigned ints and such. When I try to make Json objects using the initialization syntax with these other integer types, I see errors like:
conversion from ‘long int’ to ‘const json11::Json’ is ambiguous
Is there any interest in supporting other integer types? This project uses c++11, so it would be possible to use templates along with the "integral" concept. Maybe the JsonInt class could become a JsonInt class where std::is_integal is true.
If this idea won't work with this code or the maintainers aren't interested, my project will use a version of json11 with a duplicate a lot of code and having a lot of s/Int/Long and such. If the decision of this conversation is not to use a template+concept approach, let me know if I should submit a pull request for a version of this project with extra boilerplate for other integer types.
The text was updated successfully, but these errors were encountered:
In the interest of maximal compatibility, json11 will implicitly take the number types which it knows are compatible, and require the user to perform explicit casts in cases where truncation/rounding might be necessary.
Thanks for the answer. A remark for anybody who visits this page with the same thoughts I had: as mentioned in the link pretty much any number type can be safely cast as a double so that's the lowest-common denominator solution that makes sense.
That's true for most number types, but be cautious that it's not necessarily safe for a 64-bit (or larger) integer (because a double contains only 53 bits of precision, so would need to round), or for a long double (which would also need to round).
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
I'm trying to use this json serializer with long ints and unsigned ints and such. When I try to make Json objects using the initialization syntax with these other integer types, I see errors like:
conversion from ‘long int’ to ‘const json11::Json’ is ambiguous
Is there any interest in supporting other integer types? This project uses c++11, so it would be possible to use templates along with the "integral" concept. Maybe the JsonInt class could become a JsonInt class where std::is_integal is true.
If this idea won't work with this code or the maintainers aren't interested, my project will use a version of json11 with a duplicate a lot of code and having a lot of s/Int/Long and such. If the decision of this conversation is not to use a template+concept approach, let me know if I should submit a pull request for a version of this project with extra boilerplate for other integer types.
The text was updated successfully, but these errors were encountered: