Attempt to get()
a numeric value as a type which cannot represent it should throw
#2310
Closed
1 task done
Labels
state: please discuss
please discuss the issue or vote for your favorite option
state: stale
the issue has not been updated in a while and will be closed automatically soon unless it is updated
What is the issue you have?
Attempt to
get()
a numeric value as a type which cannot represent it should throw.If a value is not reasonably representable as the type, the conversion should fail.
Please describe the steps to reproduce the issue.
Link to godbolt for the example above: https://godbolt.org/z/cs4a9s
What is the expected behavior?
get
ting negative numbers as unsigned should throwget
ting numbers too big for the target type should throwget
ting numbers too small for the target type should throwget
ting floating point numbers as integers should throwstatic_cast<int>(j.get<double>())
. However, this is still a somewhat reasonable behavior, so changing it would probably not be backward compatible.I cannot imagine anyone relying on the current behavior of the first 3 cases, so I think fixing that should not break compatibility.
And what is the actual behavior instead?
Truncated values are printed (see example).
Which compiler and operating system are you using?
+ the linked godbolt
Which version of the library did you use?
The text was updated successfully, but these errors were encountered: