
Are there any potential problems with using sizeof() to determine which type to return? Is there a better method that is more aware of the actual ranges supported by the types?
sizeof() is insufficient since we need to know how to promote between for example, int and unsigned int. There is also the possibility that you might want to promote from int to double, but whether to allow this becomes questionable as one reaches the magnitude that suffers loss of precision. I have an implementation for the common arithmetic types that I would be prepared to submit. In my experience of using arithmetic type promotion and demotion it is often desirable to allow customisation of the promotion policy through a template parameter while providing a default policy that always preserves accuracy. Regards, Neil Groves