
On 1/28/2012 12:38 PM, Robert Ramey wrote:
I've taken a careful look at this library as part of something else I'm working on. Its really hard to understand how the library is supposed to be used and what facilities it provides. The usage of policies makes it clear that one can customize it, but the default policies don't seem to be explained.
I added some documentation for the way to customize policies, but didn't get the new docs properly into the 1.48 release branch on time for the release. The new docs are in the release trunk. There is an example that shows how to override the default policies for a custom numeric type using the numeric_cast_traits specialization. For example, I had a simple question:
if I use the library with the default policies to convert an unsigned char with a value of 128 to a signed char, what will happen? Will an exception be thrown (which is what I want) or will something else happen.
I believe the default behavior for the range checker is to see if the new type's range as defined in numeric_limits<new type> can represent the number. If the number falls out of that range the overflow handler will fire. There the default behavior is to throw an overflow exception (positive or negative).
Brandon